Invalid request - invalid web api url

I am working on a web-api and I set the web configuration file to accept 6144 as the maximum URL length as shown below

<system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime maxUrlLength="6144" relaxedUrlToFileSystemMapping="true" targetFramework="4.5"/> 

When I call api with 299 characters, everything works fine, but with more than 299 characters it gives an invalid request - invalid URL

sample url:

http://localhost:56835/api/multibuys/10270001C1001034900|10358419P4001027620|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|10781772P4805004950|

+4
source share
1 answer

I had the same problem when I was dealing with web api myself. I would suggest that the limit you click on is the default UrlSegmentMaxLength value from Http.sys.

To fix this, you need to add a new DWORD registry in

HKEY_LOCAL_MACHINE \ SYSTEM \ CurrentControlSet \ Services \ HTTP \ Parameters

enter image description here

called UrlSegmentMaxLength , and specify the value you want:

UrlSegmentMaxLength 260 0 - 32,766 characters The maximum number of characters in the segment of the URL (the area between the slash in the URL). If zero, this is the length that is limited by the maximum ULONG value.

Literature:
https://serverfault.com/questions/66410/iis-6-on-x64-and-long-urls
http://support.microsoft.com/kb/820129

+6
source

Source: https://habr.com/ru/post/1494686/


All Articles