In SharePoint how do you get the url of the page you are on from the code behind? e.g. with the blah.aspx page included...
SPContext.Current.Web.Url gives http://vm/en/
I need it with http://vm/en/Pages/blah.aspx
Select Get Link from the menu. 2. Click the SharePoint menu option and select Copy to copy the URL.
Types of URLs in SharePoint An absolute URL specifies a full path and begins with a protocol. For example, http:// domain_or_server/[ sites/ ] Web_Site/ Lists / List_Title/ AllItems. aspx . A domain-relative URL is based on the domain (which might be the name of a server) address and always begins with a forward slash.
In SharePoint (among other things), URLs can be of two different types, absolute and relative. The absolute URL for an object is the full path direct to that object, where the relative URL is an abbreviated path that combines the base URL and the current location.
URL for a SharePoint Server Site or Subsite In the URL, the site name appears immediately after the server name., for example, https://*servername/site* or https://*servername/site/subsite* .
You can still get the HttpContext and then use HttpContext.Current.Request.Url
SPContext.Current.Web is the SPWeb surrounding the page you're on, and thus its URL is the URL of the Web, not the page.
Try: SPContext.Current.File.Url
You could also use HttpContext.Current.Request.Url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With