Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm inheriting an ASP.NET application that is hosted within the IIS SharePoint web site. From IIS, right click the Web Site, and click 'Add Application' is the method used here.

In our dev server, where the 'owner' of the application set it up, SPContext is being populated as we would expect. However, in production, SPContext is null.

I have also created my own test SharePoint Web Application, and I added a standard Visual Studio ASP.NET Web App into this to test the SPContext issue...Unfortunately SPContext is null.

DEV Server

Existing App : SPContext != null

Test App : SPContext == null

Prod Server

Existing App : SPContext == null

Test App : SPContext == null

What am I missing that it takes to get SPContext populated? I've tried SPContext.GetContext(HttpContext.Current), but SPContext.Web is null then. Ideas?

share|improve this question

1 Answer 1

up vote 0 down vote accepted

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]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.