简体   繁体   中英

IIS6 Wildcard mapping breaks .net custom errors

We use a custom urlrewiter on our .net sites and set a wildcard mapping to redirect any request to the .net isapi filter for processing.

This works fine but we have noticed an issue with our custom 404 pages not working and iis handling the 404s instead. We configure the custom errors in the web.config as follows

<customErrors mode="On">
  <error statusCode="404" redirect="/404.aspx"/>
  <error statusCode="500" redirect="/500.htm"/>
</customErrors>

I noticed that the custom errorpage is served if I request an page with an aspx extension (www.mysite.com/madeuppage.aspx) but not an invalid directory (www.mysite.com/madeupdirectory/). I guess this is because IIS is passing aspx pages to the .NET enginbe for handling but I thought the wildcard mapping would pass directorys too?

This could be fixed by me configuring the custom error page in IIS but I would rather this be configured in the web.cofig if possible? Any ideas?

IIS passes 404 request to modules, but executes only several events:

IIS_BeginRequest /qwe
IIS_AuthenticateRequest
IIS_AuthorizeRequest
IIS_ResolveRequestCache
IIS_PostResolveRequestCache
IIS_EndRequest/qwe

I'm one of developers of Helicon Ape ( http://www.helicontech.com/ape ). And actually the events above were executed within Ape when I requested non-existent page. You may try Ape because it has both URL rewriting and custom error solutions. Example:

ErrorDocument 500 http://www.domain.com/cgi-bin/tester
ErrorDocument 404 /custom_error_page.htm
ErrorDocument 403 "Sorry, the access is forbidden"

If it's relevant, the syntax is text-based and Apache compatible.

your custom url Rewriter is a HttpModule implementation? I presume your solution is there, but that depends on the implementation itself. If you HANDLE any request, it doesnt matter if is an .aspx or an .xxx or a Directory.

For Example: In one of our products we depeloped an HttpModule Url Rerwriter, using RegularExpressions to capture paths or extensions or whatever in the URI to process that request depending some bussiness logic.

Maybe you want something in between. I dont understand your problem globally

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM