Httpcontext.Current.Session Is Null When Routing Requests

HttpContext.Current.Session is null when routing requests

Got it. Quite stupid, actually. It worked after I removed & added the SessionStateModule like so:

<configuration>
...
<system.webServer>
...
<modules>
<remove name="Session" />
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
...
</modules>
</system.webServer>
</configuration>

Simply adding it won't work since "Session" should have already been defined in the machine.config.

Now, I wonder if that is the usual thing to do. It surely doesn't seem so since it seems so crude...

Session values returning null

Found the issue... and feel like an idiot. Even though I went and closed all the instances in IIS Express and my running Services, there was another instance of the project being ran somewhere, thus confusing my session items.

To make sure I had everything up to date, I went in and modified the port number
(Right click Project -> Properties)

Sample Image

After doing so, everything worked as expected. This might be a very unique case, but wanted to post just in case someone might run into a similar situation.

HttpContext.Current.Session is null while calling async webservices

I ended up with the decision to refactor the whole project.

HttpContext.Current.Session is null requesting images. Why?

Why would you need a session for retrieving a static file?

Unless you are using a dynamic handler, there is absolutely no need for session to retrieve such content.

My point is that session does not serve any useful purpose for retrieving static content, so it is not available.



Related Topics



Leave a reply



Submit