错误的请求 - 无效的URL网页API [英] Bad Request - Invalid URL web api
问题描述
我工作的一个Web API和我已经设置了网络配置文件,接受6144作为URL的最大长度如下
I am working on a web-api and I have set the web config file to accept 6144 as the max length of the url as below
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxUrlLength="6144"
relaxedUrlToFileSystemMapping="true"
targetFramework="4.5"/>
当我把299个字符一切工作正常,但有超过299个字符它提供了一个错误的请求的API - 无效的网址
When I call the api with 299 characters everything works fine, but with more than 299 characters it serves up a Bad Request - Invalid URL
样品网址:
<$c$c>http://localhost:56835/api/multibuys/10270001C1001034900|10358419P4001027620|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|$c$c>
推荐答案
我在自我托管Web的API有同样的问题。我猜你打的限制是 UrlSegmentMaxLength
默认从Http.sys的。
I've had the same issue when self hosting web-api. I would guess the limit you are hitting is the UrlSegmentMaxLength
default from Http.sys.
要解决这个问题,你需要添加的新的的下
To fix this you need to add a new registry DWORD under
HKEY_LOCAL_MACHINE \\系统\\ CurrentControlSet \\服务\\ HTTP \\参数
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\HTTP\Parameters
名为 UrlSegmentMaxLength
,并给这个你想要的值:
called UrlSegmentMaxLength
and give this the value you desire:
UrlSegmentMaxLength 260 0 - 32,766字符URL路径段的最大字符数(在URL中斜杠之间的部分)。如果为零,它是受ULONG最大值的限制长度。
UrlSegmentMaxLength 260 0 - 32,766 chars Maximum number of characters in a URL path segment (the area between the slashes in the URL). If zero, it is the length that is bounded by the maximum value of a ULONG.
参考文献:结果
<一href=\"http://serverfault.com/questions/66410/iis-6-on-x64-and-long-urls\">http://serverfault.com/questions/66410/iis-6-on-x64-and-long-urls
http://support.microsoft.com/kb/820129
这篇关于错误的请求 - 无效的URL网页API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!