我有一個MVC應用程序和正在使用的路由/控制器/動作/編號MVC RouteConfig允許/Controller/Action.html
我想這還捕捉/Controller/Action.html
作爲網址,並以及和點標準routeconfig到/controller/action
也。
我正在使用我無法控制的jQuery庫,並且函數需要指向網頁或圖像的url。然而,它似乎並不理解沒有擴展名(.html,.php等)的結尾是指向html的鏈接並引發錯誤。
編輯:我試着作爲下面的評論者建議,仍然似乎無法得到它的工作。這是我的路由配置。
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute("routeWithHtmlExtension",
"{controller}/{action}.html",
new { controller = "Home", action = "Index" }
);
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
}
該URL的工作原理:
http://localhost:14418/Album/Test
這一個不:
http://localhost:14418/Album/Test.html
http://stackoverflow.com/questions/9331516/asp-net-mvc-routing-add-html-extension-to-routes –