SetWeb Doesn't Appear to Work...

Feb 20, 2013 at 6:39 PM
Edited Feb 20, 2013 at 6:41 PM
I've got this code in a _layouts/*.aspx page that I access via Central Admin. Even though I'm calling SetWeb() using another web's URL (in a different web app), the property bag returned is always that of the current context's (Central Admin) Web App.

Why doesn't SetWeb() work in this case?
using (SPSite site = new SPSite(""))
    using (SPWeb web = site.RootWeb)
        // aside: if you're using SetWeb, these enum labels become ambiguous, since I should no longer be using the "Current" anything.
        propertyBag = config.GetPropertyBag(ConfigLevel.CurrentSPWebApplication); 

        if (config.ContainsKeyInPropertyBag("setting1", propertyBag))
            settings.UrlsToHit = config.GetFromPropertyBag<List<string>>("setting1", propertyBag);
            configExists = true;
        //... etc.