Question

Je hérite d'une application ASP.NET hébergée dans le site Web IIS SharePoint.De IIS, cliquez avec le bouton droit sur le site Web, puis cliquez sur 'Ajouter une application' est la méthode utilisée ici.

Dans notre serveur Dev, où le "propriétaire" de l'application le configurait, SPContext est en cours de remplissage comme on peut s'y attendre.Cependant, en production, SPContext est NULL.

J'ai également créé mon propre test SharePoint Web Application et j'ai ajouté une application Web Visual Studio ASP.NET Standard pour tester le problème SPContext ... Malheureusement SPContext est NULL.

Dev Server

Application existante: SPContext!= NULL

Application de test: SPContext== NULL

Prod Server

Application existante: SPContext== NULL

Application de test: SPContext== NULL

Qu'est-ce que je manque que cela prend pour que SPContext peuplé?J'ai essayé SPContext.getContext (httpcontext.current), mais SPContext.Web est null alors.Idées?

Était-ce utile?

La solution

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]

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top