我一直在尝试在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"/>
这给了我一个不同的错误 – .net 404错误页面.
我将以下内容添加到我的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 = "" } );
任何建议都会得到很好的收获,因为我已经用尽了现在的所有选项.
非常感谢.
解决方法
好的,搞定了.
问题是我使用msbuild自动化来打包我需要部署的文件,而我缺少global.asax.
因此,如果没有将global.asax部署到站点,那么没有任何路由被连接起来.这意味着正确访问网站根目录会导致错误“传入的请求与任何路由都不匹配.”,并且任何其他请求不再被路由到您的控制器类,因此导致404.
HTH.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。