我继承了在IIS SharePoint网站中托管的ASP.NET应用程序。从IIS,右键单击网站,然后单击“添加应用程序”是此处使用的方法。

在我们的dev服务器中,应用程序的“所有者”设置它,SpContext正在填充我们期望的。但是,在生产中,spcontext为null。

我还创建了自己的测试SharePoint Web应用程序,我将一个标准的Visual Studio ASP.NET Web应用程序添加到此以测试spcontext问题...不幸的是spcontext是null。

dev服务器

现有应用:spcontext!= null

测试应用程序:spcontext== null

prod服务器

现有应用程序:spcontext== null

测试应用程序:spcontext== null

我错过了它需要填充spcontext的东西?我尝试了spcontext.getContext(HttpContext.Current),但Spcontext.Web是null。想法?

有帮助吗?

解决方案

Immediately after posting this, I had an idea. None of the web applications that are failing have a "Root" site collection. Technically there is no such thing as a root site collection, but I created one in the Prod Server > Existing App (at the '/' managed path) and things magically started working.

So it seems that SPContext somehow is defaulting to WebApplication.Sites[0]

许可以下: CC-BY-SA归因
scroll top