In asp.net-mvc, would a querystring too long resul

2019-04-26 09:01发布

I have an asp.net-mvc site and I have a case where I have a very long querystring in a URL. This was previously not an issue but I am suddenly getting this error in a few cases:

enter image description here 404-File or director not found - the resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

I haven't proven that its due to url length but the reason I am assuming that this is related to length of querystring is that if I selected remove certain parts of the query string it works fine and I have gone through each section (to identify of part of the query string is "corrupt"

I am able to reproduce this error in my example that has a total url length of 2805 characters. Is this expected? I see the issue in both Firefox and Internet Explorer.

The reason I ask is that from my googling, it seems like IIS throws a different error when querystring is too long (415 or 414 error as described here)

Is this something that is set on the server side? in the web.config?

3条回答
干净又极端
2楼-- · 2019-04-26 09:22
<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxQueryString="xxxx"/>
    </requestFiltering>
  </security>
</system.webServer>

See

http://www.iis.net/ConfigReference/system.webServer/security/requestFiltering/requestLimits

https://msdn.microsoft.com/en-us/library/e1f13641(v=vs.100).aspx

查看更多
Anthone
3楼-- · 2019-04-26 09:23

It seems like IIS throws a non-standard 404.15 error code for very long query strings. This is probably overshadowed by the default error handler and the actual error is mapped to bare 404 error.

Read this for details: http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

查看更多
孤傲高冷的网名
4楼-- · 2019-04-26 09:37

Per MSDN:

When request filtering blocks an HTTP request because an HTTP request exceeds the request limits, IIS 7 will return an HTTP 404 error to the client and log one of the following HTTP statuses with a unique substatus that identifies the reason that the request was denied:

| HTTP    | Substatus Description     | 
|---------|---------------------------|
|  404.13 | Content Length Too Large  |
|  404.14 | URL Too Long              |
|  404.15 | Query String Too Long     | 

FYI - 2048 is generally considered the highest cross-browser limit for a URL length.

查看更多
登录 后发表回答