【发布时间】:2014-01-13 06:41:56
【问题描述】:
我已经为路由做了这么多
routes.MapRoute(
name: "Hidden1",
url: "EditCategoryDetails/{categoryId}",
defaults: new { controller = "TestController", action = "EditCategory", categoryId = UrlParameter.Optional
});
routes.MapRoute(
name: "Hidden2",
url: "CategoryDetails",
defaults: new { controller = "TestController", action = "CategoryView"
});
routes.MapRoute(
"Default",
"{controller}/{action}/{id}",
new { controller = "LoginController", action = "Login", id = UrlParameter.Optional
});
完成此操作后,控制器和操作名称已从 Url 中删除,并分别替换为 EditCategoryDetails 和 CategoryDetails。
问题是路由后 js and css won't work 而 url 是 localhost/mywebsite/CategoryDetails
当我在地址栏末尾手动放置 斜杠(//) 时,它正在工作
localhost/mywebsite/CategoryDetails/
搜索完js和css的问题我也做了这个
routes.IgnoreRoute("{file}.css");
routes.IgnoreRoute("{file}.js");
routes.IgnoreRoute("{file}.jpg");
routes.IgnoreRoute("{file}.gif");
但没有希望。 js和css只有在浏览器地址栏最后手动添加slash(/)时生效。
我在_Layout.cshtml页面中包含js和css为
<link href="~/Content/Site.css" rel="stylesheet" />
<script src="~/Scripts/jquery-1.7.1.js"></script>
等等
【问题讨论】:
-
你能发布你如何尝试包含 js 和 css
-
请检查。我也添加了 dat @VolodymyrBilyachat
标签: asp.net-mvc asp.net-mvc-4 asp.net-mvc-routing url-routing