asp.net 3.5自定义错误404不适用于非aspx页面 [英] asp.net 3.5 custom error 404 not working for non aspx pages

查看:63
本文介绍了asp.net 3.5自定义错误404不适用于非aspx页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我正在一个使用asp.net 3.5开发的网站上,我在其中使用以下代码来处理不存在的页面

Hi all,I am working on a website which is developed in asp.net 3.5 , in which i have used following code to handle not existing pages

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">           
            <error statusCode="404" redirect="FileNotFound.htm" />
        </customErrors>




现在我输入网址
例如http://mysite/Notexist.aspx

它将我重定向到FileNotFound.htm

但是当我输入类似

例如http://mysite/Notexist.htm

它不起作用,它向我显示了旧的iis页面,说页面未找到..

我不知道为什么这不起作用..

请帮助我


问候.




Now whwn I Type The url
e.g. http://mysite/Notexist.aspx

it redirects me to FileNotFound.htm

but when i type something like

e.g. http://mysite/Notexist.htm

it does not work it shows me the old iis page saying page not found..

i don''t know why this does not working..

Please help me


Regards.

推荐答案

那是因为请求未到达ASP.NET引擎,而是由IIS本身处理的.您将需要添加一个映射到.htm页面的处理程序.
对于IIS 7,请执行以下步骤:
That''s because the request doesn''t reach the ASP.NET engine and is handled by IIS itself. You will need to add a handler mapping to .htm pages.
For IIS 7, follow the following steps:
Open IIS and click on your website. Select 'Handler Mapping' from the right pane. There are 'Actions' listed on the extreme right and select 'Add Script Map'.
Enter *.htm in the Request Path field.
Give the path to aspnet_isapi.dll in the executable field. (Should be here: C:\Windows\Microsoft.NET\Framework\v2.0.50727\aspnet_isapi.dll. If it isn't here check Framework64 folder).
Finally give a name to the handler. Say Html.
Click Okay and try again now.


希望这会有所帮助!


Hope this helps!


这篇关于asp.net 3.5自定义错误404不适用于非aspx页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆