admin管理员组文章数量:1134246
I have a MVC3 site in C#, I have a particular view being fed query parameters from a JavaScript function, the function redirects to the site via
window.location.href = "../ActionName?" + query_string;
query_string being the dynamic query parameters string built by the JavaScript function.
The reason for this weirdness is that sometimes the same function passes the URL to an ASP.Net webform due to it having to use the reportviewer control, the alternate action is to save some parameters in this case it passes to the view. (Can elaborate more if that does not make sense)
The whole thing works fine until I introduce [Authorize] to the action method. Breaks if it is in place, works fine without, and [Authorize] works fine on all the other methods.
The whole URL in this case is 966 chars long, after research it seems that the maxQueryStringLength value is 2048 by default but can overridden to any value of type integer, so just for grins I added the
<security>
<requestFiltering>
<requestLimits maxQueryString="2048"></requestLimits>
</requestFiltering>
</security>
key to the web config file under the key.
No joy there, so I got ridiculous and made it 4096, still no joy.
Now with the whole URL being 966 chars long, the authorize attribute cannot seriously be adding another 1082-3130 chars, so how can I determine what the error actually is, or why the setting is not taking effect.
VS2010 Pro SP1
I have a MVC3 site in C#, I have a particular view being fed query parameters from a JavaScript function, the function redirects to the site via
window.location.href = "../ActionName?" + query_string;
query_string being the dynamic query parameters string built by the JavaScript function.
The reason for this weirdness is that sometimes the same function passes the URL to an ASP.Net webform due to it having to use the reportviewer control, the alternate action is to save some parameters in this case it passes to the view. (Can elaborate more if that does not make sense)
The whole thing works fine until I introduce [Authorize] to the action method. Breaks if it is in place, works fine without, and [Authorize] works fine on all the other methods.
The whole URL in this case is 966 chars long, after research it seems that the maxQueryStringLength value is 2048 by default but can overridden to any value of type integer, so just for grins I added the
<security>
<requestFiltering>
<requestLimits maxQueryString="2048"></requestLimits>
</requestFiltering>
</security>
key to the web config file under the key.
No joy there, so I got ridiculous and made it 4096, still no joy.
Now with the whole URL being 966 chars long, the authorize attribute cannot seriously be adding another 1082-3130 chars, so how can I determine what the error actually is, or why the setting is not taking effect.
VS2010 Pro SP1
Share Improve this question edited Jan 9, 2015 at 3:36 nempoBu4 6,6219 gold badges38 silver badges41 bronze badges asked Nov 16, 2011 at 21:57 SabreSabre 2,3902 gold badges19 silver badges26 bronze badges 1- Please add the detailed error message you are receiving. – counsellorben Commented Nov 16, 2011 at 22:03
5 Answers
Reset to default 241In the root web.config
for your project, under the system.web
node:
<system.web>
<httpRuntime maxUrlLength="10999" maxQueryStringLength="2097151" />
...
In addition, I had to add this under the system.webServer
node or I got a security error for my long query strings:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxUrl="10999" maxQueryString="2097151" />
</requestFiltering>
</security>
...
When an unauthorized request comes in, the entire request is URL encoded, and added as a query string to the request to the authorization form, so I can see where this may result in a problem given your situation.
According to MSDN, the correct element to modify to reset maxQueryStringLength in web.config is the <httpRuntime>
element inside the <system.web>
element, see httpRuntime Element (ASP.NET Settings Schema). Try modifying that element.
i have this error using datatables.net
i fixed changing the default ajax Get to POST in te properties of the DataTable()
"ajax": {
"url": "../ControllerName/MethodJson",
"type": "POST"
},
For anyone else that may encounter this problem and it is not solved by either of the options above, this is what worked for me.
1. Click on the website in IIS
2. Double Click on Authentication under IIS
3. Enable Anonymous Authentication
I had disabled this because we were using our own Auth, but that lead to this same problem and the accepted answer did not help in any way.
i got this problem and i solved it like this (the value of the atributtes maxRequestLength, maxQueryStringLength and maxQueryString may be different for your application):
in web.config
put this line in <system.web>
<system.web>
<httpRuntime targetFramework="4.5" maxRequestLength="10240" maxQueryStringLength="32768" />
</system.web>
and in system.webServer, write
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxQueryString="32768"/>
</requestFiltering>
</security>
</system.webServer>
that's worked for me. I hope this helps someone.
本文标签: crequest exceeds the configured maxQueryStringLength when using AuthorizeStack Overflow
版权声明:本文标题:c# - request exceeds the configured maxQueryStringLength when using [Authorize] - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736803995a1953610.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论