Reputation: 26501
I have set up custom 404 and it works. But when I try to access some file that does not exist it shows good ol' ASP.NET 404.0 error page.
I've tried to add <error statusCode="404.0" redirect="/notfound/?" />
but it does not work since statusCode
should be integer.
http://localhost:123/das/dsagfdsa
will redirect to http://localhost:123/notfound/?
http://localhost:123/das/dsagfdsa.png
will stay and show 404.0
error.
<customErrors mode="On" redirectMode="ResponseRedirect" defaultRedirect="/notfound/?">
<error statusCode="404" redirect="/notfound/?" />
</customErrors>
How do I make sure it will redirect to /notfound/
not only on wrong page requests but also on wrong file requests?
Upvotes: 0
Views: 1352
Reputation: 13921
You have to configure this in IIS. By default, only specific files will get routed through the ASP.NET framework, otherwise IIS will handle it (configured as shown below in the 'Error Pages' section of IIS).
Alternatively, you could configure ASP.NET to handle other file types as well. For more info on this, read about Handler Mappings.
Upvotes: 1