mvc路由 html,asp.net-mvc – ASP.NET MVC路由从html页面开始
我正在使用IIS 6.我想我的問題是我不知道如何使用routes.MapRoute路由到一個(gè)非控制器.
我有一個(gè)url,如example.com,我希望它為index.htm頁面提供服務(wù),而不是使用MVC.我該如何設(shè)定?在IIS中,我將index.htm作為我的起始文檔,我的global.asax具有標(biāo)準(zhǔn)的“默認(rèn)”路由,其中??它調(diào)用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
);
}
我補(bǔ)充說:
protected void Application_BeginRequest(object sender, EventArgs e)
{
if (Context.Request.FilePath == "/") Context.RewritePath("index.htm");
}
有用.但這是最好的解決方案嗎?
總結(jié)
以上是生活随笔為你收集整理的mvc路由 html,asp.net-mvc – ASP.NET MVC路由从html页面开始的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 车牌云d是哪里的车
- 下一篇: 麒麟980评测跑分参数详细介绍