gpt4 book ai didi

asp.net - 路由 HTTP 错误 404.0 0x80070002

转载 作者:行者123 更新时间:2023-12-02 11:38:16 26 4
gpt4 key购买 nike

我已经在 ASP.NET 应用程序中创建了路由规则,并且在 IIS7 的开发计算机上一切正常。当我将解决方案部署到也具有 IIS7 的产品服务器时,我在访问 URL 时收到错误 404(未找到页面)。也许有人可以指出问题出在哪里?

实际错误

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 文件中,现在一切在生产服务器上也工作正常。

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

关于asp.net - 路由 HTTP 错误 404.0 0x80070002,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5677099/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com