2015-04-08

Long length URL cause Invalid Url error

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

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

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.

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

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


After above setting

Add this into Web.config

<system.web>  
    <httpRuntime targetFramework="4.5" maxQueryStringLength="4096" maxUrlLength="4096" />
</system.web>