I tried to access a WCF Service through jQuery AJAX call with GET method. So, sometimes the URL is lengthy with parameters.

我尝试使用GET方法通过jQuery AJAX调用访问WCF服务。所以,有时候URL的参数很长。

When the parameters becomes so lengthy, jQuery AJAX Call fails, and returns nothing. So I put a break point and took the URL out to test. When I try the same URL in the browser (I tried FireFox and Chrome), it returns the following when the URL length is too long.

当参数变得如此冗长时,jQuery AJAX调用会失败,并且不会返回任何内容。所以我放了一个断点,取出URL进行测试。当我在浏览器中尝试相同的URL(我尝试了FireFox和Chrome)时,当URL长度太长时,它会返回如下内容。

Bad Request - Invalid URL

错误请求-无效URL

HTTP Error 400. The request URL is invalid.

HTTP错误400。请求URL无效。

I checked the length limitation as well. When the number of characters in the URL (in encoded format) exceeds 1011 characters (including http://) only I get the error.

我也检查了长度限制。当URL中的字符数(编码格式)超过1011个字符(包括http://)时,只有我得到错误。

Anyone has the same situation and found any solution to this? Is it Windows Limitation or Can it be managed through any settings programmatically?

有谁遇到过同样的情况并找到了解决办法吗?它是Windows限制还是可以通过编程方式进行管理?

I tried POST method, but I don't know I could not make it work. Because it needs some web.config changes.

我尝试过POST方法,但我不知道我无法让它奏效。因为它需要一些网络。配置更改。

EDIT

编辑

The URL I have Tested to Generate the Error

我测试的URL生成错误

http://localhost:64973/Member.svc/SaveMemberWithDetail/%7B%22ID%22%7C%222%22,%22TypeID%22%7C%222%22,%22Title%22%7C%22Mr.%22,%22FirstName%22%7C%22Firnas%22,%22MiddleName%22%7C%22%22,%22LastName%22%7C%22Aliyar%22,%22Gender%22%7C%221%22,%22DateOfBirth%22%7C%222000-01-01%22,%22Nationality%22%7C%22Sri%20Lankan%22%7D/%5B%7B%22AddressLine1%22%7C%22Changed%20Address%20Line1%22,%22AddressLine2%22%7C%22Colombo%22,%22City%22%7C%22Colombo%2010%22,%22State%22%7C%22WP%22,%22PostCode%22%7C%2201000%22,%22CountryID%22%7C%221%22,%22ID%22%7C%227%22,%22TypeID%22%7C%221%22%7D%5D/%5B%7B%22Telephone%22%7C%22015154645%22,%22TypeID%22%7C%221%22%7D%5D/%5B%7B%22EmailAddress%22%7C%22gen1@dfs%22,%22ID%22%7C%2226%22,%22TypeID%22%7C%221%22%7D,%7B%22EmailAddress%22%7C%22gen2@jfasd%22,%22ID%22%7C%2227%22,%22TypeID%22%7C%221%22%7D,%7B%22EmailAddress%22%7C%22g1@e.cm%22,%22ID%22%7C%2228%22,%22TypeID%22%7C%221%22%7D,%7B%22EmailAddress%22%7C%22g2@gogle.com%22,%22ID%22%7C%2229%22,%22TypeID%22%7C%221%22%7D,%7B%22EmailAddress%22%7C%22g@go.com%22,%22ID%22%7C%2229%22,%22TypeID%22%7C%221%22%7D%5D/%7B%7D/481

Unencoded version of URL:

未编码的URL:

http://localhost:64973/Member.svc/SaveMemberWithDetail/{"ID"|"2","TypeID"|"2","Title"|"Mr.","FirstName"|"Firnas","MiddleName"|"","LastName"|"Aliyar","Gender"|"1","DateOfBirth"|"2000-01-01","Nationality"|"Sri Lankan"}/[{"AddressLine1"|"Changed Address Line1","AddressLine2"|"Colombo","City"|"Colombo 10","State"|"WP","PostCode"|"01000","CountryID"|"1","ID"|"7","TypeID"|"1"}]/[{"Telephone"|"015154645","TypeID"|"1"}]/[{"EmailAddress"|"gen1@dfs","ID"|"26","TypeID"|"1"},{"EmailAddress"|"gen2@jfasd","ID"|"27","TypeID"|"1"},{"EmailAddress"|"g1@e.cm","ID"|"28","TypeID"|"1"},{"EmailAddress"|"g2@gogle.com","ID"|"29","TypeID"|"1"},{"EmailAddress"|"g@go.com","ID"|"29","TypeID"|"1"}]/{}/481

My Parameters are set of Json Objects. I don't think any of the characters cause the problem, because, if I just reduce few alpha numeric characters to less than the limit, it works.

我的参数是Json对象的集合。我不认为任何字符都会引起问题,因为,如果我只是将一些字母数字字符减少到小于限制,它就可以工作。

I'm running my application in Visual Studio 2012 Premium in Windows 8 Professional, so it's .NET 4.5 and IIS Express Came with it.

我在Windows 8 Professional的Visual Studio 2012 Premium版中运行我的应用程序,所以它是。net 4.5和IIS Express。

Further Research

进一步的研究

When I try to investigate this further, this is not the limitation I have already mentioned which is the length of full url. But, there is a limitation of length in each parameter which is 260 characters.

当我进一步研究这个问题时,这并不是我之前提到的限制,也就是完整url的长度。但是,每个参数的长度都是260个字符。

So, I'm not sure about URL total length, but each parameter (seperated by "/") has the limit. The problem with the above URL which I have posted is Email Address JSON parameter is 261 characters long, given below.

我不确定URL的总长度,但是每个参数(用"/"分隔)都有限制。上面我发布的URL的问题是电子邮件地址JSON参数为261个字符长,如下所示。

[{"EmailAddress"|"gen1@dfs","ID"|"26","TypeID"|"1"},{"EmailAddress"|"gen2@jfasd","ID"|"27","TypeID"|"1"},{"EmailAddress"|"g1@e.cm","ID"|"28","TypeID"|"1"},{"EmailAddress"|"g2@gogle.com","ID"|"29","TypeID"|"1"},{"EmailAddress"|"g@go.com","ID"|"29","TypeID"|"1"}]

If I delete 1 character from this, it works.

如果我从这里删除一个字符,它就可以工作了。

Is it Browser Limitation? OS Limitation?

浏览器限制吗?操作系统限制吗?

UPDATE: SOLUTION

更新:解决方案

I Found a solution which worked for me, when I research further on this. I'm updating here since it might be useful for others who come across this question.

当我进一步研究这个问题时,我找到了一个对我有用的解决方案。我在这里更新,因为它可能对遇到这个问题的其他人有用。

This is an IIS Setting

这是IIS设置

The problem is because, the default character limit of each parameter in REST url is 260 which is defined in the registry.

问题在于,REST url中每个参数的默认字符限制是260,这是在注册表中定义的。

So, you have to update the registry to increase this size limit where the IIS Server / IIS Express is running.

因此,您必须更新注册表,以增加IIS服务器/ IIS Express正在运行的地方的大小限制。

Following is the location of Registry:

以下是登记处的地址:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters

And the value name is UrlSegmentMaxLength. If it is not there, create one with Type of REG_DWORD. And specify a higher value for value data such as 1000 in hexadecimal or 4096 in decimal.

值名是UrlSegmentMaxLength。如果它不在那里,创建一个带有REG_DWORD的类型。并为值数据指定较高的值,如十六进制的1000或十进制的4096。

This is a http.sys setting. More about http.sys settings : http://support.microsoft.com/kb/820129

这是一个http。系统设置。更多关于http。系统设置:http://support.microsoft.com/kb/820129

Make sure, you restart the server/machine to apply the registry changes. And that's it.

确保重新启动服务器/机器以应用注册表更改。就是这样。

5 个解决方案

#1


8

Reposting the update as Answer, since some of you might jump directly into the Answers section.

将更新作为答案重新发布,因为有些人可能直接跳到Answers部分。

I Found a solution which worked for me, when I research further on this. I'm updating here since it might be useful for others who come across this question.

当我进一步研究这个问题时,我找到了一个对我有用的解决方案。我在这里更新,因为它可能对遇到这个问题的其他人有用。

This is an IIS Setting

这是IIS设置

The problem is because, the default character limit of each parameter in REST url is 260 which is defined in the registry.

问题在于,REST url中每个参数的默认字符限制是260,这是在注册表中定义的。

So, you have to update the registry to increase this size limit where the IIS Server / IIS Express is running.

因此,您必须更新注册表,以增加IIS服务器/ IIS Express正在运行的地方的大小限制。

Following is the location of Registry:

以下是登记处的地址:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\Parameters And the value name is UrlSegmentMaxLength. If it is not there, create one with Type of REG_DWORD. And specify a higher value for value data such as 1000 in hexadecimal or 4096 in decimal.

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\HTTP\参数和值名称为UrlSegmentMaxLength。如果它不在那里,创建一个带有REG_DWORD的类型。并为值数据指定较高的值,如十六进制的1000或十进制的4096。

This is a http.sys setting. More about http.sys settings : http://support.microsoft.com/kb/820129

这是一个http。系统设置。更多关于http。系统设置:http://support.microsoft.com/kb/820129

Make sure, you restart the server/machine to apply the registry changes. And that's it.

确保重新启动服务器/机器以应用注册表更改。就是这样。

更多相关文章

  1. 为什么在使用jquery读写表单输入时必须对字符串进行编码?
  2. [求助]如何用JQuery来实现Ctrl+Space完成输入特定字符提示的自动
  3. 将参数传递给jQuery的select2 ajax调用
  4. 如何设置请求标头字符串[重复]
  5. Bootstrap Multiselect插件使用步骤以及常见参数配置介绍
  6. Jquery验证插件,获取错误字符串
  7. JQuery攻略(三)数组与字符串
  8. 通过调用返回参数的本地函数来构建Ajax Data部分
  9. 在中的元素的自定义子弹符号,这是一个普通字符,而不是一个图像

随机推荐

  1. JS内存泄漏排查方法
  2. 函数和递归
  3. 视频演示:好家伙,我直接好家伙!
  4. 深入React
  5. 今晚,我等你 ~
  6. 分布式系统的事务处理
  7. 都想学大数据开发?年轻人耗子尾汁吧~
  8. 今天的南京,很冷很冷
  9. vertical-align刨根问底
  10. CSS上下左右居中