如何将所有页面扩展名重定向到asp.net项目中未找到的自定义404页面? [英] How redirect all page extensions to custom 404 not found page in an asp.net project?
问题描述
我正在尝试在asp.net项目中创建一个自定义页面.我为404未找到错误创建了一个页面.这是Web配置的一部分:
I'm trying to make a custom page in my asp.net project. I created a page for 404 not found errors. Here is a part in web config:
<customErrors mode="On" defaultRedirect="Errors.aspx">
<error statusCode="404" redirect="404.aspx"/>
</customErrors>
当我像"(websitename)/asdfasdf.aspx "这样写到Web浏览器时,可以看到我创建的自定义错误页面,但是当我写"(websitename)/asdfasdf ",我看到"服务器错误/404-找不到文件或目录."页面(默认错误"页面).
When I write to web browser like "(websitename)/asdfasdf.aspx", I can see to custom error page which I created, but when I write "(websitename)/asdfasdf", I see "Server Error / 404 - File or directory not found." page (Default Error page).
您知道如何将所有页面扩展名重定向到我的自定义错误页面吗?
Do you know how can I redirect all page extensions to my custom error page?
推荐答案
我找到了解决方案.我正在使用托管到我的网站,因此在托管中,有一个设置可以设置"404 not found"页面.所以,它解决了.
I found the solution. I am using hosting to my website, so in hosting there was a setting to set 404 not found page. So, It solved.
这篇关于如何将所有页面扩展名重定向到asp.net项目中未找到的自定义404页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!