views:

239

answers:

2

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?

A: 

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

gonxalo
The problem is that the .NET engine does not even get the request to handle. IIS process the request and returns its own 404 without passsing the request to .NET. Im not sure why as the global wildcard deals with this for the rewriter?
Sheff
A: 

Hello, 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.

Slava
Ok, Ill take a look at ape but I think if I we still use our own rewriter, what you are saying here is get my custom url rewriter to deal with custom error pages rather than leave it up to the .NET engine?
Sheff
I beg a pardon for delay. You may use your custom module to handle those responses. Though it depends on the module implementation, I believe it’s possible. If Ape could do so, your module would be able too.
Slava