Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
924 views
in Technique[技术] by (71.8m points)

asp.net - IIS 404 Custom Error not working as expected

I'm working on IIS6, ASP.NET, VS2008. The web site uses a custom error handler to catch 404 errors and serve an alternate page. When presented with an url of the form:

http://srv/crimson/articles/index

Everything works perfectly. But an url of the form:

http://srv/crimson/blog.aspx

Where blog.aspx does not exist, fails with the following message:

Server Error in '/Crimson' Application. Description: HTTP 404...

When I try and debug, none of the breakpoints in my 404 handler are hit. So it appears that something is catching the request earlier. Where? And how to I get it to pass the request on to my handler?

Edit Thanks to those who answered, but none of those ideas worked. I've decided to attack the problem another way.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You might wanna try this:

In IIS6:

  • open "properties" for your website
  • go to "home directory" tab
  • click on "configuration"
  • look for the extension ".aspx"
  • click on "edit"
  • check the checkbox which says "verify that file exists"

edit

And what about this: http://msdn.microsoft.com/en-us/library/h0hfz6fc(VS.80).aspx

<customErrors defaultRedirect="sorry.htm" mode="On">  
     <error statusCode="404" redirect="NotFound.aspx"/>
</customErrors>

Since 'RemoteOnly' specifies that custom errors are shown only to the remote clients, and that ASP.NET errors are shown to the local host.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...