我需要找到给定站点的 Web 应用程序的 URL(假设我有一个 URL http://code/sites/java。给定此网站集的 URL,我需要托管此网站集的 Web 应用程序的 URL。在此如果是 http://code。) 任何输入将不胜感激。
最佳答案
如果您有一个 SPWeb 对象,请使用它的 Site属性(property)。如果您有一个 SPSite 对象,请使用它的 WebApplication属性(property)。如果您都没有,create an SPSite object从那个网址。
从 SPWebApplication 对象使用 AlternateUrls属性(property)。
来自 SPAlternateUrlCollection对象检索您所需区域的 SPAlternateUrl。
来自 SPAlternateUrl对象获取实际的 URL。
您需要通过备用 URL 集合的原因是因为您可以使用备用访问映射 associate with a web application .比如所有的web应用都以Default开头,可以扩展到Intranet、Extranet等。
记得根据需要对上述对象使用 dispose。
关于sharepoint - 如何在给定站点 URL 的情况下找到 SharePoint Web 应用程序的 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1542586/