Reputation: 326
I have a ASP.NET WebAPI application and some of the request exceed the maximum lenght. That's fine, I know I can increase the limit either in IIS or web.config, but that's not my point.
When I read the contents of the request using one of the Request.Content.Read
methods all of them return a Maximum request length exceeded
exception.
I would like to retrieve the first characters of the body though, for logging purposes.
Is it still possible to read just the first characters of the body? Or is the whole content impossible to retrieve?
Upvotes: 2
Views: 284
Reputation: 11
you must catch the exception on global.asax file, then you will have the request data.
see these 2 links:
Catching "Maximum request length exceeded" http://geekswithblogs.net/sglima/archive/2011/09/20/how-to-handle-maximum-request-length-exceeded-exception.aspx
Upvotes: 1