ASP.NET MVC: How to Handle 400 Request Error Errors When URL Ends%

I try to handle all HTTP errors on my own error pages, but I find that when there is% at the end of the URL, I cannot use the configuration setting or the code to handle it, for example: http: // localhost / abc% answer: Invalid request - Invalid HTTP Error 400 URL. Invalid request URL.

So, can we use the configuration setting or C # code to handle this error request?

+4
source share
2 answers

See this 4-series series for customizing custom error pages in IIS: http://www.dotnetscraps.com/dotnetscraps/post/Did-you-know-Enable-Custom-Error-in-IIS-7-75.aspx .

I personally prefer to use the Application_Error event to register errors and redirect users to user error pages. Note that you need to use the integrated piping line in IIS to catch all errors, otherwise IIS will display its error page for resources that are not served by ASP.NET.

EDIT: Sorry for the wrong answer. I have an XP machine currently that shows 404 for the% sign, so the above could not be verified. When searching over the Internet, I found that it was simply not possible to display a user error page for a 400 status code . See this server error question for more information.

+2
source

Who said this is not possible?

Response.TrySkipIisCustomErrors = true; 

OR

 <configuration> <system.webServer> <httpErrors existingResponse="PassThrough" /> </system.webServer> </configuration> 

original message

+3
source

All Articles