Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

Get the current context of the site where web-part is added in the same site collection

$
0
0

Hi,

I'm creating a visual web-part in SharePoint 2013 using server object model (can't user COM as the code will run on the same server) to get all the members of "Members" group of the site/web wherever this web-part will be added (in the same site-collection), so it will take the context of the site wherever it is added.For Eg: I have a site collection "http://<Server_name>/sites/Finance" OR "http://<Server_name>/sites/Finance/Microsoft" OR some other subsite. I have used SPContext.Current property to get the current context , but no success :( . 

I tried in SPSite: SPContext.Current.Site ; new SPSite(SPContext.Current.Web.URL) and many other combinations with SPSite.

in SPWeb : site.openweb()

But I'm always getting the URL as "http://<Server_name>/" and not the context where the web-part is added in the same site collection.


Vipul Jain


Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>