Muhammad Iqbal
Muhammad Iqbal

Reputation: 1

Deployment Issue: (MVC4 HotTowel SPA)

I have developed a web application using VS2012 MVC 4 (HotTowel SPA) If I run it through Visual Studio it works fine. But when I deploy it to IIS server I am getting an exception.

My server machine is Server 2008 R2 and IIS version 7.5. All the dependencies are installed.

The code section causing error:

On index.cshtml page If check if(Session["User"] == null) then load view Login. (Login.cshtml) If session is not null then load the home view. Everything is working fine if running through visual studio. If I remove the Session check then home page is loaded successfully. But I must check the session before going to home. But I get the following exception:

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Line 65:
Line 66: @if (Session["User"] == null) Line 67: { Line 68: @Html.Partial("Login")
}

Upvotes: 0

Views: 100

Answers (1)

Muhammad Iqbal
Muhammad Iqbal

Reputation: 1

I found the solution to my problem Just add this module to your web.config file.

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

It is very strange that Microsoft did add this module in Template.

Upvotes: 0

Related Questions