mvc路由 html,asp.net-mvc – ASP.NET MVC路由从html页面开始
我正在使用IIS 6.我想我的問題是我不知道如何使用routes.MapRoute路由到一個非控制器.
我有一個url,如example.com,我希望它為index.htm頁面提供服務,而不是使用MVC.我該如何設定?在IIS中,我將index.htm作為我的起始文檔,我的global.asax具有標準的“默認”路由,其中??它調用Home / Index.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
我補充說:
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/") Context.RewritePath("index.htm");
}
有用.但這是最好的解決方案嗎?
總結
以上是生活随笔為你收集整理的mvc路由 html,asp.net-mvc – ASP.NET MVC路由从html页面开始的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车牌云d是哪里的车
- 下一篇: 网站部署后无法访问sqlserver_.