Adicionando o aplicativo da Web ASP.NET ao diretório virtual do SharePoint (para SpContext)
-
09-12-2019 - |
Pergunta
Estou herdando um aplicativo ASP.NET hospedado no site do IIS SharePoint.Do IIS, clique com o botão direito do mouse no site e clique em 'Adicionar aplicativo' é o método usado aqui.
Em nosso servidor DEV, onde o 'proprietário' do aplicativo configurou, o SPContext está sendo preenchido como esperamos.No entanto, na produção, o SPContext é nulo.
Eu também criei meu próprio aplicativo Web do Test SharePoint, e adicionei um aplicativo Web do Visual Studio do Visual ASP.NET para testar a questão do SpContext ... Infelizmente o SPContext é NULL.
server servidor
App existente: spContext!= null
teste de teste: spContext== null
server prog
App existente: spContext== null
teste de teste: spContext== null
O que estou perdendo que é necessário para obter o SpContext preenchido?Eu tentei spcontext.getcontext (httpcontext.current), mas spcontext.web é nulo então.Ideias?
Solução
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]