开发者

How to get SPWebApplication from SPWeb?

开发者 https://www.devze.com 2023-02-10 21:10 出处:网络
So I\'m inside a web scroped feature (properties.Feature.Parent = SPWeb). How do I get the SPWebApplication from this SPWeb?

So I'm inside a web scroped feature (properties.Feature.Parent = SPWeb).

How do I get the SPWebApplication from this SPWeb?

I tried:

SPWebApplication w开发者_如何学GoebApp = (SPWebApplication)properties.Feature.Parent;

But of course I get an exception because I cannot cast the SPWeb object as an SPWebApplication.


You can try:

SPWeb web = properties.Feature.Parent as SPWeb;
SPWebApplication webApp = web.Site.WebApplication;
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号