我在SharePoint页面中有一些代码试图获取当前使用的Web App和Zone的提供程序信息。
此代码正确找到区域名称:
SPWebApplication app = SPContext.Current.Site.WebApplication;
SPAlternateUrl u = app.AlternateUrls[Request.Url];
SPUrlZone zone = u.UrlZone;
区域将返回“自定义”或“默认”,具体取决于使用的URL /服务器。
接下来,我尝试使用以下代码获取该区域的IIS设置:
SPIisSettings settings = app.IisSettings[zone];
我在测试“自定义”网站/网址(AAM)时遇到异常。似乎无论我从哪个URL / Server访问该网站,app.IisSettings []只包含“默认”的“密钥”。
我错过了什么?
谢恩
答案 0 :(得分:0)
尝试使用:
SPWebApplication iisApp = SPWebApplication.Lookup(Request.Url);
SPIisSettings settings = iisApp.IisSettings[zone];
获取不同区域的IisSettings。由于SPContext可能会返回默认IIS Web应用程序。