当使用请求超过所配置的maxQueryStringLength [授权] [英] request exceeds the configured maxQueryStringLength when using [Authorize]

查看:1461
本文介绍了当使用请求超过所配置的maxQueryStringLength [授权]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

结果
我已经在C#中MVC3的网站,我有一个JavaScript函数被送入查询参数的特定视图,该功能通过


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;

window.location.href = "../ActionName?" + query_string;

QUERY_STRING由JavaScript函数建立动态查询参数字符串。

query_string being the dynamic query parameters string built by the JavaScript function.

这样做的原因是古怪,有时同一个函数传递URL以一个ASP.Net Web窗体,由于它不必使用的ReportViewer 的控制,交替动作是保存在这一些参数情况下,它传递给图。 (能否详细说明更多的如果没有意义)

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.

在这种情况下,整个URL为966个字符长,经过研究似乎在 maxQueryStringLength 值为2048默认,但可以覆盖到整数类型的任意值,从而只是笑着我增加了

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.

没有喜悦在那里,所以我得到可笑,并使其4096,仍然没有喜悦。

No joy there, so I got ridiculous and made it 4096, still no joy.

现在与整个URL为966个字符长,授权属性不能被认真又增加1082-3130个字符,这样我怎么能确定什么错误实际上是,或者为什么设置不生效。

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 SP1专业版

VS2010 Pro SP1

推荐答案

在未经授权的请求时,整个请求的URL连接codeD,并添加作为查询字符串的请求,授权的形式,所以我能看到这可能会导致你给出一个局面的问题。

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.

根据MSDN,正确的元素来修改web.config中重置maxQueryStringLength是&LT;的httpRuntime&GT; &LT内部元件;系统名.web&GT; 元素,看到的httpRuntime元素( ASP.NET设置架构)。尝试修改该元素。

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.

这篇关于当使用请求超过所配置的maxQueryStringLength [授权]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆