Aggiunta dell'applicazione Web ASP.NET alla directory virtuale SharePoint (per SPContext)
-
09-12-2019 - |
Domanda
I'e ereditando un'applicazione ASP.NET che è ospitata all'interno del sito Web di IIS SharePoint.Da IIS, fai clic con il tasto destro del mouse sul sito Web e fai clic su "Aggiungi applicazione" è il metodo utilizzato qui.
Nel nostro server Dev, in cui il "proprietario" dell'applicazione lo ha impostato, SpContext viene popolato come ci aspetteremmo.Tuttavia, nella produzione, SpContext è nullo.
Ho anche creato la mia applicazione Web di Test SharePoint e ho aggiunto un'app Web di Visual Studio ASP.NET standard in questo per testare il problema SPConText ... Purtroppo SpContext è NULL.
Dev Server
App esistente: SPCONTEXT!= NULL
Test App: SPCONTEXT== NULL
Prod Server
App esistente: SPCONTEXT== NULL
Test App: SPCONTEXT== NULL
Cosa mi manca che ci vuole per ottenere PContext popolato?Ho provato spcontext.getcontext (httpContext.current), ma spContext.web è nullo allora.Idee?
Soluzione
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]