0

Web サイトに URL ルーティング構造を使用しています。URL ルーティング (特にマルチ セグメント) を使用すると、css ファイルと js ファイルが読み込まれません。

void RouteMap(RouteCollection route)
{
    route.RouteExistingFiles = false;
    route.Ignore("{resource}.axd/{*pathInfo}"); //Not work
    routes.Ignore("{resource}.css/{*pathInfo}"); //Not work
    routes.Ignore("Styles/{*pathInfo}"); //Not work
    routes.Ignore("Styles/"); //Not work

    route.MapPageRoute("", "Guide", "~/Guide.aspx");
    route.MapPageRoute("", "Guide/{key}", "~/Guide.aspx");
    route.MapPageRoute("", "Search/{key}", "~/Search.aspx");
}

void Application_Start(object sender, EventArgs e)
{
    RouteMap(RouteTable.Routes);
}

<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<script src="~/Scripts/jquery.min.js" type="text/javascript"></script>
4

3 に答える 3

2

これを試して:

<link href="/Styles/Site.css" rel="stylesheet" type="text/css" />

<script src="/Scripts/jquery.min.js" type="text/javascript"></script>

CSS または JS ファイル パスを「 / 」で開始する必要があります --> src="* / *Scripts/jquery.min.js"

于 2013-02-11T05:04:57.923 に答える
1

クラシック モードを使用した場合は、アプリケーションに IIS 統合アプリケーション プール (.NET ランタイムによって処理される css ファイル用) を使用してみてください。

于 2012-08-10T10:05:35.250 に答える
0
colRoutes.RouteExistingFiles = False

colRoutes.Ignore("{*allaxd}", New With {.allaxd = ".*\.axd(/.*)?"})
colRoutes.Ignore("{*allaspx}", New With {.allaspx = ".*\.aspx(/.*)?"})
colRoutes.Ignore("{*allascx}", New With {.allascx = ".*\.ascx(/.*)?"})
colRoutes.Ignore("{*allashx}", New With {.allashx = ".*\.ashx(/.*)?"})
colRoutes.Ignore("{*allhtm}", New With {.allhtm = ".*\.htm(/.*)?"})
colRoutes.Ignore("{*allhtml}", New With {.allhtml = ".*\.html(/.*)?"})
colRoutes.Ignore("{*allcss}", New With {.allcss = ".*\.css(/.*)?"})
colRoutes.Ignore("{*alljs}", New With {.alljs = ".*\.js(/.*)?"})
colRoutes.Ignore("{*allpng}", New With {.allpng = ".*\.png(/.*)?"})
colRoutes.Ignore("{*allgif}", New With {.allgif = ".*\.gif(/.*)?"})
colRoutes.Ignore("{*alljpg}", New With {.alljpg = ".*\.jpg(/.*)?"})
colRoutes.Ignore("{*alltif}", New With {.alltif = ".*\.tif(/.*)?"})
colRoutes.Ignore("{*allico}", New With {.allico = ".*\.ico(/.*)?"})
colRoutes.Ignore("{*allttf}", New With {.allttf = ".*\.ttf(/.*)?"})
colRoutes.Ignore("{*alleot}", New With {.alleot = ".*\.eot(/.*)?"})
colRoutes.Ignore("{*allsvg}", New With {.allsvg = ".*\.svg(/.*)?"})
colRoutes.Ignore("{*allwoff}", New With {.allwoff = ".*\.woff(/.*)?"})
于 2014-08-21T15:53:00.523 に答える