Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can an ASP.NET HttpHandler handle an http 400 - Bad Request?

We have an HttpHandler that deals directly with binary posts over HTTP from custom client software. The client software occasionally sends data which results in IIS 7 responding with a 400 - Bad Request. Since the "400 Bad Request" is special in that HTTP.SYS transparently handles it in kernel mode without notifying user mode of anything, no errors are raised to be handled in ASP.NET. Is it possible to catch this http 400 in ASP.NET, so that I can write specific data to the Response stream in these scenarios? A redirect to another page isn't an option as it needs to be in the current Request/Response.

like image 359
John Lemp Avatar asked Dec 04 '08 21:12

John Lemp


1 Answers

If you know what is causing the 400, then you may be able to customise the behaviour of http.sys via the registry to deal with it:

http://support.microsoft.com/kb/820129

However, you should be aware that there are potential security and performance ramifications of doing this.

Another option would be to use a filtering proxy before IIS, thereby capturing the request before it goes any further.

like image 113
Dave R. Avatar answered Oct 01 '22 11:10

Dave R.