SharePoint Get Current Web URL
How to get SharePoint site current URL ?
We can get SharePoint Current web url in Server-Side as well as in Client side.
But in SharePoint 2013, we can access web url as below as well :
We can get SharePoint Current web url in Server-Side as well as in Client side.
Server Side:
As we all know current web url can be accessed in server side by web object as below.SPContext.Current.Web.Url
Client Side:
In client side , we can achieve this by using SPServices .
Here is how to achieve this:
Include SPServices js file in your page.
Now you can access the url this way:
var thisWebUrl = $().SPServices.SPGetCurrentSite();But there is a bug in recent versions of SPServices , where the above method will return only "/".
But in SharePoint 2013, we can access web url as below as well :
Enjoy coding :)var thisWebUrl = _spPageContextInfo.webAbsoluteUrl; (web url)var thisSiteUrl = _spPageContextInfo.siteAbsoluteUrl; (site url)
Comments
Post a Comment