我正在为我的网站使用 url 路由结构。当我使用 url 路由(尤其是多段)时,我的 css 和 js 文件未加载。我使用了 Route.Ignor 但不起作用。
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>