Microsoft SharePoint URL lengths

SharePoint 2007/2010/2013/2016/2019 instances have a default maximum allowed length of 260 characters for URLs submitted to their APIs.

To set up a datasource that will potentially go into items whose encoded URLs are longer than 260 characters, you need to increase the length that the APIs will accept.

Understanding URL lengths

Note that the length mentioned above refers to encoded URLs as in HTML URL encoding which usually makes URL lengths increase.

For example, compare:

  • the normal URL path /exampleSubsite/Folder/file (27 characters)

  • its URL encoded form %2FexampleSubsite%2FFolder%2Ffile (33 characters)

The SharePoint API sees the longer string, not the shorter string.

Increasing the maximum URL length

To increase the maximum allowed URL length:

  1. Locate the SharePoint ISS’s configured web.config file

    Usually it’s in C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config

  2. Back up web.config in case you need to roll back your changes

  3. In web.config, search for system.web httpRuntime:

        <httpHandlers />
        <customErrors mode="On" />
        <httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />
  4. Edit the httpRuntime element to set the maxUrlLength attribute to an appropriate value. For example, you could set it to the maximum observed encoded URL length plus 100:

        <httpHandlers />
        <customErrors mode="On" />
        <httpRuntime maxRequestLength="51200" maxUrlLength="5000" requestValidationMode="2.0" />
  5. Save web.config, overwriting the existing file

  6. Restart the SharePoint ISS service