I'm trying to handle errors and show appropriate pages for 404, 403 and so on.
To do so, I've made an ErrorHandling filter and It works as expected. Namely, when I try to request
mysite.com/Home/random_non-existent_action
user is redirected to my custom 404 page and returned 404 as response code. Same applies for 401 and 403 as well.
I' ve achieved this with Error Handling filter and modification made on web.config as :
This is where the problem starts, our customer wants to customize IIS' error pages as well, for instance when I request
mysite.com/images,
IIS error page is being shown because directory browsing is disabled and because this is prevented at IIS-level, my error handling filter does not work.
To override IIS error pages, I'v added below code to web.config
Now with both customErrors and httpErrors are present in my web.config, when I request
mysite.com/Home/random_non-existent_action
my custom 404 page is shown (because It's by-passed by IIS and my error handling filter works). But when I request
mysite.com/content
or
mysite.com/images
I'm getting a blank response with 404 status code.
When I change responseMode to Redirect (instead of ExecuteURL), It works. But clearly I'm trying to navigate to my custom error pages with relative paths.
1-Why am I getting a blank response when I try to override IIS custom error pages?
2-Why does It work when I make responseMode="Redirect" but not responseMode="ExecuteURL"
Any help would be greatly appreciated as I've searched many similar stackoverflow topics with no success.
I've tried all combinations for existingResponse and responseMode values. Anything except responseMode="Redirect" makes it go blank with corresponding status code.
EDIT :
What I've done in the end is,
Write html content and redirect to my custom error pages with javascript.