Long URL’s in SharePoint 2010


I had a co-worker recently ask me about some of the incredibly long URL’s now used in SharePoint 2010.  In SharePoint 2007, the URL to a document hosted in a document library looked something like http://sharepoint/sites/teamsite/project%20documents/mydoc.xls. Great for cutting and pasting into an e-mail.  After upgrading the SharePoint 2007 farm to SharePoint 2010, right-clicking on that same document and copying the URL would result in something that looked like

http://sharepoint/sites/teamsite/_layouts/xlviewer.aspx?id=/sites/teamsite/project%20documents/mydoc.xls&Source=http%3A%2F%2Fsharepoint%2Fsites%2Fteamsite%2Fproject%20documents%2FForms%2FAllItems%2Easpx%3FRootFolder%3D%252Fsharepoint%252Fsites%252Fteamsite%252Fproject%documents%26View%3D%7B391E5EDC%2DAA9C%2D4F64%2D9E8D%2D401965CFC83A%7D&DefaultItemOpen=1

Not so good for cutting and pasting into an e-mail, right?  Why did the URL length grow so long when referring to the same document for which SharePoint 2007 had such a nice short URL?

Lake Chargoggagoggmanchauggagoggchaubunagungamaugg by Bree Bailey.
SharePoint 2010 is not the only place with long names.  Picture by Bree Bailey

First… the why.  You will see this behavior if you are using Office Web Apps with SharePoint 2010.  That long URL tells SharePoint to open the document in Office Web App, allowing you to read the spreadsheet or word document without downloading it locally and opening it in your local installation of Office.  That’s why the first part of the URL references /_layouts/xlviewer.aspx or /_layouts/PowerPoint.aspx or /_layouts/WordViewer.aspx

image
PowerPoint in the browser, courtesy of Office Web Apps

What if you just want to link directly to the document itself?  Some e-mail programs limit the length of URLs, as do places within SharePoint itself (Document Link content types can only be 260 characters, and links within “Current Navigation” are also limited).  The link to the open-in-web-apps-view is usually too long. 

Let’s deconstruct the long url:

http://sharepoint/sites/teamsite/_layouts/xlviewer.aspx?id=/sites/teamsite/project%20documents/mydoc.xls&Source=http%3A%2F%2Fsharepoint%2Fsites%2Fteamsite%2Fproject%20documents%2FForms%2FAllItems%2Easpx%3FRootFolder%3D%252Fsharepoint%252Fsites%252Fteamsite%252Fproject%documents%26View%3D%7B391E5EDC%2DAA9C%2D4F64%2D9E8D%2D401965CFC83A%7D&DefaultItemOpen=1

  • The protocol = http://
  • Server Name: sharepoint
  • The URL to Office Web Apps: /sites/teamsite/layouts/xlviewer.aspx
  • Parameter saying what document to open: ?id=/sites/teamsite/project%documents/mydoc.xls
  • Parameter explaining where SharePoint should go if you close the Web App view (the URL is URL encoded and includes the path and view for the folder storing the document): &Source=http%3A%2F%2Fsharepoint%2Fsites%2Fteamsite%2Fproject%20documents%2FForms%2FAllItems%2Easpx%3FRootFolder%3D%252Fsharepoint%252Fsites%252Fteamsite%252Fproject%documents%26View%3D%7B391E5EDC%2DAA9C%2D4F64%2D9E8D%2D401965CFC83A%7D
  • Parameter specifying to open the item in Web App view (I am guessing on this one… changing =1 to =0 doesn’t seem to do anything): &DefaultItemOpen=1

Pretty sure your eyes are crossed at this point… this is way more than you wanted to know.  Anyhoo… the point I was trying to make is… out of that ginormous URL, it is relatively easy to extract the path to the document itself.  That source parameter is only necessary for Web Apps, and it takes up a lot of spac.  Just combine the protocol with the server name with the parameter saying where the document is (in our example above, http://sharepoint/sites/teamsite/project%documents/mydoc.xls.   It’s easier done than said Smile

The other way to change the behavior away from long URLs (and back to the way SharePoint 2007 worked) is to change the default document opening behavior.  You must be a Site Collection Administrator to do so, and simply go to:

  1. Site Settings
  2. Under Site Administration –> Site Library and Lists
  3. Select the list of interest
  4. Under General Settings –> Advanced Settings
  5. Under Opening Documents in the Browser –> chose radio button to Open in the Client Application
  6. OK

image

Now you will notice that right-clicking on a document and selecting the URL will leave you with a nice short URL.  Hope this helps someone!

Comments (24)

  1. Anonymous says:

    nice job!

  2. Greg Osimowicz says:

    Good write-up. Shame the URLs can't be shortened through some sort of aliasing or redirection. Users actually love Office Web Apps and often disabling it wouldn't go down too well 🙂

    ___________________________________

    Sharepoint Resource Center

    sharepointresourcecenter.com

  3. refurbished used pc says:

    i am so pleased with this blog the knowledge which has been shared through a blog is extremely useful for me.i really appreciate the blogger for doing  this effort.

  4. refurbished used pc says:

    i am so pleased with this blog the knowledge which has been shared through a blog is extremely useful for me.i really appreciate the blogger for doing  this effort.

  5. refurbished computers says:

    i have been pleased after reading this blog the knowledge which has been provided via this blog is simply tremendous.

    i really appreciate the blogger for doing  this work.

  6. Lubos says:

    Hello I have problem with this URL. I am using xlsm files. Its openning in browser fine. But when I create libray and in this library i create many folders and subfolders, the URL is too long. And in this case, when try to open xlsm file, i got error: an error has occured (when i move xlsm to root level, it works fine again).

    Is there any limit on Sharepoint? Any Recommendation how is maximum length for URL ?

  7. Jeff25 says:

    There is a Thrid Party Add-On that offers this functionality and is simple to install and use.

    Worth taking a look. Our Users Love it!

    http://sharepointshorturl.com

  8. Thank you, thank you, thank you for the nice write-up. Just what I wanted.

  9. Ben says:

    Great article – we've coded this up in JavaScript, if anyone would like to use:

    http://www.brdalby.co.uk/sharepoint-links

  10. Umkclag0 says:

    Can you provide a breakdown of the url for a document set similar to the document above – what is the critical portion

  11. Simple Utility for SharePoint URL Shortening says:

    I wrote a little web page that fixes many of these easily:

    http://www.qa76.net/shortener

    Just put in the URL and follow the instructions.  Copies to your clipboard for easy pasting.

  12. I know this is old however... says:

    You know SharePoint 2010 can work exactly the same way as 2007?

    So, in 2007 when you had the URL:

     http://sharepoint/sites/teamsite/project%20documents/mydoc.xls

    The url now looks like:

     http://sharepoint/sites/teamsite/project%20documents/mydoc.xls

    I know that there is a lot of extraneous extras in the URL usually when navigate and copy and paste from the URL, but you don't need to use that at all. This is OOB functionality and you don't need to buy any extra software to use it.

    Leathal.

  13. Thank you! says:

    Thank you so much, I've been looking for why this was happening all over the web.

    (Same thing happens in SharePoint 2010)

  14. Need Help for SP2013 says:

    Hello,

    Is there a counterpart of the fix in SP2013 On Premise? I tried to enable the “Open Documents in Client Applications by Default ” in Site Collection features as the option is no longer available in SP2013 but still the URL has encoded value ?Source=https%3A%2F%2F

  15. Need Help for SP2013 says:

    Hello,

    Is there a counterpart of the fix in SP2013 On Premise? I tried to enable the “Open Documents in Client Applications by Default ” in Site Collection features as the option is no longer available in SP2013 but still the URL has encoded value ?Source=https%3A%2F%2F

  16. Need Help for SP2013 says:

    Hello,

    Is there a counterpart of the fix in SP2013 On Premise? I tried to enable the “Open Documents in Client Applications by Default ” in Site Collection features as the option is no longer available in SP2013 but still the URL has encoded value ?Source=https%3A%2F%2F

  17. Need Help for SP2013 says:

    Hello,

    Is there a counterpart of the fix in SP2013 On Premise? I tried to enable the “Open Documents in Client Applications by Default ” in Site Collection features as the option is no longer available in SP2013 but still the URL has encoded value ?Source=https%3A%2F%2F

  18. @asandford says:

    This is exactly what I needed to figure out what was going on. This only happens for Excel files in our environment. I worked around it by opening the workbook and copying the "real" url from the File tab.

  19. Torey says:

    How do i do this in 2013?

  20. DAAS says:

    double thumbs-up! i like this! giving the "why and what" instead of just the "how". thanks much

  21. Imppress says:

    I had Sharepoint complainign about long Document Link names even when they were NOT 260 characters.

    Copied and pasted into word, find/replaced the %20 portions with spaces (what %20 codes for) and tried to make THAT the link’s URL and sunuvagun, it worked! Sharepoint knows what to do with spaces in the URL.

  22. juliaop says:

    I have download **Long Path Tool** and it is the best solution of these kind of problems.

    regards,

  23. anton says:

    I found some paid solution for this issue. It was described in article
    http://www.pathtoolong.com/applications/filename-too-long-error-in-sharepoint and that custom software is located at the same website.