We're building an application on the following stack:
- .NET 4.6.1
- ASP.NET MVC 5
- IIS 8
We have people generating very long search filter query strings in our application. Currently the resulting GET requests result in an exception on the server. We'd like to warn them if their request string is going to be too long, rather than submitting an invalid GET request.
Our .js guy can shim AJAX requests to support length checking for the full URL and the querystring pretty easily. The problem is we don't want to assume we know the right maximum lengths for those values. We want to query the server to know what the maximum lengths for the URL and querystring are, and just use that dynamically on the client side.
I can build the Web API endpoint to return those values very easily, but I'm having trouble being certain I'm getting the right values. For example, I can read our configuration file directly and look for things like this:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxUrl="2000" maxQueryString="2000" />
</requestFiltering>
</security>
</system.webServer>
However, I'm not certain that is really the authoritative place to look. I'm hoping somebody knows how to use C# to ask IIS the following questions and be certain of having the right answers:
- What is the maximum allowed URL length for a GET request to the current application?
- What is the maximum allowed querystring length for a GET request to the current application?