Gid*_*sey 6 asp.net asp.net-mvc iis-7 url-routing
我有一个现有的ASP.NET 3.5 WebForms项目,并已将ASP.NET MVC添加到该项目中.现有页面工作正常,新控制器和视图也是如此.但是,当我部署到IIS 7时,默认文档(default.aspx)不再起作用.如果我明确地键入它,我可以得到它但是'xyz.com'不起作用 - 我得到404.相比之下,它在Cassini中工作正常.
如何在保留新MVC内容的同时再次使默认文档正常工作.
Gid*_*sey 10
我将以下内容添加到Global.asx.cs文件中,默认文档再次起作用.
public static void RegisterRoutes(RouteCollection routes)
{
// *** This Line ***
routes.IgnoreRoute(""); // Required for the default document in IIS to work
// *****************
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{resource}.aspx/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Home", action = "Index", id = "" } // Parameter defaults
);
}
protected void Application_Start(Object sender, EventArgs e)
{
RegisterRoutes(RouteTable.Routes);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2683 次 |
| 最近记录: |