本文介绍了路由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?
实际错误
我的实际代码
<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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!