加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – IIS 6上的ASP.NET MVC – 通配符映射 – 传入请

发布时间:2020-12-15 22:30:48 所属栏目:asp.Net 来源:网络整理
导读:我一直在尝试在IIS 6上设置我的Beta 1 MVC应用程序,但无法正常运行.我已经按照其他博客文章的建议添加了.net isapi DLL的通配符映射,但是当我访问网站的根目录时出现以下错误: The incoming request does not match any route...[HttpException (0x80004005
我一直在尝试在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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读