ajax请求不适用于mvc4中的最大查询字符串 [英] ajax request not working for max query string in mvc4

查看:64
本文介绍了ajax请求不适用于mvc4中的最大查询字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨团队,



我的json ajax请求无法处理mvc 4代码中的最大查询字符串。

我的网址没有打到控制器jsonresult动作。

当我发送小号没有。查询字符串然后它的工作。

你能不能帮我解释它为什么不起作用。



以下是我的代码。



Hi team,

My json ajax request not working on max query string in mvc 4 code.
my url not hit the controller jsonresult action.
when i send small no . of query string then its working.
Can you any body help me why its not working.

Below is my code.

strSelecteds = strSelecteds.substring(0, strSelecteds.length - 1);
$.ajax({
    url: "/Usermanagement/AddProxyGroupMapping?jsonValue=" + strSelecteds + '&IsInsert=' + IsInsert + '&PackageId=' + packegeId + '&Allocate=' + Allocate,
    type: 'POST',
    contentType: 'application/json;charset=utf-8'
});





strSelecteds字符串的最大记录长度超过1000。

我在webconfig文件中使用下面的代码,但它不起作用。





The strSelecteds string have the max record with more the 1000 length.
I am using below code in webconfig file but its not working .

<system.web.extensions>
  <scripting>
    <webServices>
      <!-- Try increasing this value to a larger value (Int.MaxValue used below) -->
      <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
    </webServices>
  </scripting>
</system.web.extensions>





我想知道,如何通过mvc4中的ajax请求处理最大记录



问候,

Ravi Sharma



I want to know , how to handle max record through ajax request in mvc4

regards,
Ravi Sharma

推荐答案

.ajax({
url: / Usermanagement / AddProxyGroupMapping?jsonValue = + strSelecteds + ' & IsInsert =' + IsInsert + ' & PackageId =' + packegeId + ' & Allocate =' +分配,
类型:' POST'
contentType:' application / json; charset = utf-8'
} );
.ajax({ url: "/Usermanagement/AddProxyGroupMapping?jsonValue=" + strSelecteds + '&IsInsert=' + IsInsert + '&PackageId=' + packegeId + '&Allocate=' + Allocate, type: 'POST', contentType: 'application/json;charset=utf-8' });





strSelecteds字符串的最大记录长度超过1000。

我在下面使用webconfig文件中的代码,但它不起作用。





The strSelecteds string have the max record with more the 1000 length.
I am using below code in webconfig file but its not working .

<system.web.extensions>
  <scripting>
    <webServices>
      <!-- Try increasing this value to a larger value (Int.MaxValue used below) -->
      <jsonSerialization maxJsonLength="2147483644"></jsonSerialization>
    </webServices>
  </scripting>
</system.web.extensions>





我想知道,如何通过mvc4中的ajax请求处理最大记录



问候,

Ravi Sharma



I want to know , how to handle max record through ajax request in mvc4

regards,
Ravi Sharma


由于您要发布,请不要像使用GET一样发送数据。设置固定路径

/ Usermanagement / AdProxyGroupMapping然后使用

data:发送你需要的东西



像这样:

Since you're posting, do not send the data as if you're using GET. Set the fixed path
/Usermanagement/AdProxyGroupMapping and then use
"data: " to send what you need

like this:
strSelecteds = strSelecteds.substring(0, strSelecteds.length - 1);


.ajax({
url: / Usermanagement / AddProxyGroupMapping
type:' POST'
data:{' jsonValue':strSelecteds,< span class =code-string>' IsInsert':IsInsert,' PackageId':packageId,' 分配':分配}
contentType:' application / json; charset = utf-8'
});
.ajax({ url: "/Usermanagement/AddProxyGroupMapping", type: 'POST', data: {'jsonValue': strSelecteds, 'IsInsert': IsInsert, 'PackageId': packageId, 'Allocate': Allocate } contentType: 'application/json;charset=utf-8' });







您可能需要调整一下,数据需要是JSON,也许我拼错了一些东西,但是发送长查询字符串(IE中限制为大约2000个字符,总共4000个字符)不是很好想法。



由于您使用的是POST方法,请将数据发送至帖子。





如果这有帮助,请花时间接受解决方案。谢谢。




You might need to tweak this, data needs to be JSON, maybe I misspelled something, but sending long query string (which is limited to around 2000 characters in IE and 4000 total) is not a good idea.

Since you are using POST method, send the data as for post.


If this helps please take time to accept the solution. Thank you.


这篇关于ajax请求不适用于mvc4中的最大查询字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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