hussian
hussian

Reputation: 399

Session values not found after redirect

In the Asp.net MVC Project I am redirecting my users to another page after login.

On the development environment all my session variables return null.

On Production however this works fine and session variables are retrieved correctly.

can some One please explain why all variables are null on the development environment.

 [AllowAnonymous]
 [HttpPost]
 public ActionResult Login(LoginModel model, string returnUrl)
 {
    // Some validations 

     if (Url.IsLocalUrl(returnUrl))
          {
              var urlDeCoded = HttpUtility.UrlDecode(returnUrl);
              var htmlDecoded = HttpUtility.HtmlDecode(urlDeCoded);
              return Redirect(htmlDecoded);
          }
 }

/// Retreiveing session variables
 var vm = SessionData.GetCurrentObject<MembershipWizardViewModel>();

In web.Config I have the same value for sessionState on both Envirnoments i.e. "InProc"

Upvotes: 0

Views: 2217

Answers (1)

Elo
Elo

Reputation: 2352

Do you loose your session ? I think this could be a problem of cookies : session Ids could be kept in cookies, and if you redirect on a Url which is on a different server, cookies are different, so it creates you a new session... with empty variables. A common mistake is to redirect from "localhost" to "127.0.0.1", even if it is technically the same, it could cause a lot of troubles.

Upvotes: 1

Related Questions