路由HTTP错误404.0 0x80070002 [英] Routing HTTP Error 404.0 0x80070002

查看:1068
本文介绍了路由HTTP错误404.0 0x80070002的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在ASP.NET应用程序和IIS7上的Dev机器上创建了路由规则,一切正常。当我将解决方案部署到也有IIS7的prod服务器时,我在访问URL时收到错误404(找不到页面)。也许有人可以指出问题出在哪里?

I have created routing rules in my ASP.NET application and on my Dev machine at IIS7 everything works fine. When I deploy solution to prod server which has also IIS7 I get error 404 (page not found) while accessing URL. Maybe someone could point where is the problem?

实际错误


HTTP错误404.0 - 未找到您要查找的
资源已被删除
,名称已更改,或者
暂时不可用。详细
错误InformationModule IIS Web核
通知MapRequestHandler
处理程序StaticFile错误代码
0x80070002请求的URL
http://xxx.xxx.xxx.xxx:80/pdf-button
物理路径
C:\www \ pathtoproject\pdf-button登录
方法匿名登录用户匿名

HTTP Error 404.0 - Not Found The resource you are looking for has been removed, had its name changed, or is temporarily unavailable. Detailed Error InformationModule IIS Web Core Notification MapRequestHandler Handler StaticFile Error Code 0x80070002 Requested URL http://xxx.xxx.xxx.xxx:80/pdf-button Physical Path C:\www\pathtoproject\pdf-button Logon Method Anonymous Logon User Anonymous

我的实际代码

     <add key="RoutePages" value="all,-forum/"/>

             UrlRewrite.Init(ConfigurationManager.AppSettings["RoutePages"]);


    public static class UrlRewrite
    {
            public static void Init(string routePages)
            {

                _routePages = routePages.ToLower().Split(new[] { ',' });
                RegisterRoute(RouteTable.Routes);




            }

            static void RegisterRoute(RouteCollection routes)
            {

                routes.Ignore("{resource}.axd/{*pathInfo}");
                routes.Ignore("favicon.ico");
                foreach (string routePages in _routePages)
                {
                    if (routePages == "all")
                        routes.MapPageRoute(routePages, "{filename}", "~/{filename}.aspx");
                    else
                        if (routePages.StartsWith("-"))
                            routes.Ignore(routePages.Replace("-", ""));
                        else
                        {
                            var routePagesNoExt = routePages.Replace(".aspx", "");
                            routes.MapPageRoute(routePagesNoExt, routePagesNoExt, string.Format("~/{0}.aspx", routePagesNoExt));
                        }
                }

            }
}


推荐答案

刚发现下面的行必须添加到web.config文件中,现在一切都在Prod服务器上运行正常。

Just found that lines below must be added to web.config file, now everything works fine on Prod server too.

  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" >
      <remove name="UrlRoutingModule"/>    
    </modules>
  </system.webServer>

这篇关于路由HTTP错误404.0 0x80070002的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆