我需要在下面的测试场景中将错误重定向到错误页面, http://localhost/admin800/test。 http://localhost/admin800/test:
这是我的代码,
<system.web>
<compilation debug="true" targetFramework="4.0" />
<httpRuntime targetFramework="4.0" />
<customErrors mode="On" defaultRedirect="Error1">
<error statusCode="404" redirect="/admin600/error.aspx"/>
</customErrors>
</system.web>
<system.webServer>
<directoryBrowse enabled="false" />
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL" existingResponse="Replace">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<remove statusCode="403" subStatusCode="-1" />
<error statusCode="404" path="/admin600/error.aspx" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/admin600/error.aspx" responseMode="ExecuteURL" />
<error statusCode="403" path="/admin600/error.aspx" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
让我知道我需要在此web.config中添加哪些额外的代码。我已经在Web应用程序项目中完成了项目,而不是在MVC中。请尽快收到您的回复。
提前致谢。 乔治
答案 0 :(得分:0)
我在我的应用程序中使用此代码:
<customErrors defaultRedirect="error.aspx" mode="On" />
或者这个:
<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>