我已经使用Webforms实现了路由。为此,我从.NET 3.5迁移到4.0
之后,我的web.config文件如下所示。
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="~/Error.aspx"/>
<compilation targetFramework="4.0" debug="true">
</compilation>
<authentication mode="Windows">
<forms name=".ATCookies" loginUrl="login.aspx" protection="All" timeout="5000000" cookieless="UseCookies" slidingExpiration="true" path="\"/>
</authentication>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<system.webServer>
<modules>
<remove name="UrlRoutingModule"/>
<add name="UrlRoutingModule"
type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</modules>
<handlers>
<add name="UrlRoutingHandler"
preCondition="integratedMode"
verb="*"
path="UrlRouting.axd"
type="System.Web.HttpForbiddenHandler, System.Web, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
</handlers>
</system.webServer>
</configuration>
Global.asax看起来像这样
void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
RegisterRoutes(RouteTable.Routes);
}
void RegisterRoutes(RouteCollection routes)
{
routes.MapPageRoute("TestRoute", "Test/{Brand}", "~/Test.aspx");
}
当我尝试访问类似于Test / Brand1的URL时,它可以在localhost和IIS中工作。当我将其部署到生产环境时,它将停止工作并显示错误:
404-找不到文件或目录。您正在寻找的资源可能已被删除,名称已更改或暂时不可用。
我尝试添加不起作用的runAllManagedModulesForAllRequests =“ true”属性。我根本无法确定问题所在。