SPListItem.URL Funky Return Fiesta

Man, I have never seen this before, but doing a simple SPListItem.URL and returning the URL returns a funky ass value. It looks like hex or some crap, like this:


What the hell is that? Shouldn’t the SPListItem.Url property return the actual URL to the item?

To get around this, you have to tailor your code a little bit differently.


SPList list = site.Lists.GetList(“MyList”);

SPListItem item = list.Items[id];

list.Forms[PAGETYPE.PAGE_DISPLAYFORM].Url + “?ID=” + item.ID[/csharp]

Now you will actual retrieve the correct path to the DispForm.aspx page.

Wierd, eh? :)


13 thoughts on “SPListItem.URL Funky Return Fiesta”

  1. Well part of that makes sense, you should get that unless you are appending the + “?ID=” + item.ID so that it is aware of which SPListItem ID to point to. The other part, where it is truncated “Pages” out of the name, I don’t know where it comes from.

    I have also noticed that sometimes it does not work on custom list types, which is weird, because it should. If you can post back your results it would be appreciated!

  2. Hi, thx it helped me out.

    Worked with my custom list but I had to change it a bit to not get the /Pages/ before.

    myList.Forms[PAGETYPE.PAGE_DISPLAYFORM].ServerRelativeUrl + “?ID=” + myItem.ID

  3. Seems to work for me. Might some people be getting problems with the Url if they’re using a customer display form? In which case the form might be stored inside the pages list.

    I’m just guessing here. I’ve not used customer display forms yet.

  4. Hi,

    Not sure if this helps anyone at this point, but depending on whether or not the default dispform has been changed for the list item’s content type, this might help resolve the proper display form.

    Once you have the list item, you can get the content type of the item and check the DisplayFormUrl before using the PAGE_DISPLAYFORM. For example,

    SPListItem listItem = list.GetItemById( itemId );

    SPContentType contentType = listItem.ContentType;

    string urlToItem = type.DisplayFormUrl;


Leave a Reply

Your email address will not be published. Required fields are marked *