什么是在web.config中管理404错误的当前方法 [英] what is currect way to manage 404 error in web.config
问题描述
我写在URl www.abc.com/wer.aspx(错误的页面)然后显示我的错误页面,否则我把www.abc.com/wer(错误的页面没有扩展名)然后我的错误页面没有显示。 />
请以正确的方式帮助我。
我喜欢这个...在Web Config中
< customErrors mode = RemoteOnly defaultRedirect = error.htm >
< 错误 statusCode = 401 redirect = error.htm / >
< 错误 statusCode = 402 重定向 = error.htm / >
< 错误 statusCode = 403 redirect = error.htm / >
< 错误 statusCode = 404 redirect = error.htm / >
< / customErrors >
如果要在Visual Studio中运行项目时看到错误页面,则必须将模式设置为ON。
< customErrors mode =OndefaultRedirect =error.htm>
当您将模式设置为RemoteOnly,它只向外部用户呈现错误页面。
有关详细信息,请参阅此MSDN文章:
https://msdn.microsoft.com/en-us/library/ bb397417(v = vs.140).aspx [ ^ ]
不会为nonasp.net文件调用ASP.NET处理程序。您可以强制使用asp.net处理程序通过在您的网络配置中将runAllManagedModulesForAllRequests
设置为true
来操作所有请求
< pre lang =HTML> <system.webServer >
< modules runAllManagedModulesForAllRequests = true >
< / system.webServer >
check: 404重定向非aspx页面 [ ^ ]
< blockquote>希望这可以帮助你。
< customerrors mode = RemoteOnly defaultredirect = 〜/ error.htm redirectmode = ResponseRewrite />
I write in URl www.abc.com/wer.aspx (Wrong Page) then show my error page else i put www.abc.com/wer (wrong page without extension) then my error page not show.
Please help me in proper way.
I DO LIKE THIS ...in Web Config
<customErrors mode="RemoteOnly" defaultRedirect="error.htm">
<error statusCode="401" redirect="error.htm" />
<error statusCode="402" redirect="error.htm" />
<error statusCode="403" redirect="error.htm" />
<error statusCode="404" redirect="error.htm" />
</customErrors>
If you want to see the error page when you run the project from Visual Studio, you have to set the mode to ON.
<customErrors mode="On" defaultRedirect="error.htm">
When you set mode to RemoteOnly, it renders error pages to external users alone.
Refer this MSDN article for more details:
https://msdn.microsoft.com/en-us/library/bb397417(v=vs.140).aspx[^]
ASP.NET handlers are not called for non-asp.net files.you can force the asp.net handler to operate on all requests by settingrunAllManagedModulesForAllRequests
astrue
in your web config as below
<system.webServer> <modules runAllManagedModulesForAllRequests="true"> </system.webServer>
check : 404 Redirecting for non aspx pages[^]
Hope this Helps you out.
<customerrors mode="RemoteOnly" defaultredirect="~/error.htm" redirectmode="ResponseRewrite" />
这篇关于什么是在web.config中管理404错误的当前方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!