我一直在尝试在IIS 6上设置我的Beta 1 MVC应用程序,但无法正常运行.我已经按照其他博客文章的建议添加了.net isapi DLL的通配符映射,但是当我访问网站的根目录时出现以下错误:
The incoming request does not match any route. .. [HttpException (0x80004005): The incoming request does not match any route.] System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContextBase httpContext) +147 System.Web.Routing.UrlRoutingHandler.ProcessRequest(HttpContext httpContext) +36 System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +4 HCD.Intranet.Web.Default.Page_Load(Object sender,EventArgs e) +81 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,Object o,Object t,EventArgs e) +15 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender,EventArgs e) +33 System.Web.UI.Control.OnLoad(EventArgs e) +99 System.Web.UI.Control.LoadRecursive() +47 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint,Boolean includeStagesAfterAsyncPoint) +1436
我正在使用MVC模板应用程序中提供的Default.aspx页面,该页面正确地重写对网站根目录的访问.
public partial class Default : Page { public void Page_Load(object sender,System.EventArgs e) { HttpContext.Current.RewritePath(Request.ApplicationPath); IHttpHandler httpHandler = new MvcHttpHandler(); httpHandler.ProcessRequest(HttpContext.Current); } }
如果我尝试访问应用程序中的路径,例如/ Project,我会得到标准的IIS 404错误页面,而不是.net错误页面.
我尝试将以下行添加到我的Web.config httpHandlers部分:
<add verb="*" path="*" validate="false" type="System.Web.Mvc.MvcHttpHandler,System.Web.Mvc,Version=1.0.0.0,Culture=neutral,PublicKeyToken=31BF3856AD364E35"/>
我将以下内容添加到我的Global.asax中,它没有做任何事情:
protected void Application_BeginRequest(object sender,EventArgs e) { if (Context.Request.FilePath.Equals("/")) Context.RewritePath("Default.aspx"); }
我正在使用以下路由配置(使用MvcContrib项目提供的restful路由):
routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); SimplyRestfulRouteHandler.BuildRoutes(routes); routes.MapRoute( "Default","{controller}/{action}/{id}",new { controller = "Home",action = "Index",id = "" } );
任何建议都会得到很好的收获,因为我已经用尽了现在的所有选项.
非常感谢.