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:
Locate the SharePoint ISS’s configured
web.config
fileUsually it’s in
C:\inetpub\wwwroot\wss\VirtualDirectories\80\web.config
Back up
web.config
in case you need to roll back your changesIn
web.config
, search forsystem.web httpRuntime
:<system.web> <httpHandlers /> <customErrors mode="On" /> <httpRuntime maxRequestLength="51200" requestValidationMode="2.0" />
Edit the
httpRuntime
element to set themaxUrlLength
attribute to an appropriate value. For example, you could set it to the maximum observed encoded URL length plus 100:<system.web> <httpHandlers /> <customErrors mode="On" /> <httpRuntime maxRequestLength="51200" maxUrlLength="5000" requestValidationMode="2.0" />
Save
web.config
, overwriting the existing file