Lets say I have a SharePoint List provided on URL http://webapp:1234/Lists/TestList.
In code, I have access to the corresponding SPList-Instance only. How can I get the URL of this SPList
-Instance programmatically?
The SPList class is missing an URL property or something like that...
You need to combine the list's root folder URL with the web URL. Root folder URL can be accessed via SPFolder.Url
and web's absolute URL via SPWeb.Url
. Providing you have a list
it will be something like list.ParentWeb.Url + list.RootFolder.Url
.
However, read the documentation, try it and fix things like proper slashes etc. You might also need to figure out the hostname portion of the URL from the parent SPWebApplication
object. Note that the site may be accessible via multiple hostnames because of alternate access mappings.
Also, SPUtility.GetFullUrl
may come in handy to convert a server-relative URL into a full URL.