MVC3 destroying session on redirecttoaction

后端 未结 2 737
一个人的身影
一个人的身影 2021-01-21 08:31

I have an issue with sessions in an MVC3 application. In one controller I am receiving a post request then adding the value to session before redirecting to the controllers get

相关标签:
2条回答
  • 2021-01-21 08:54

    I tryed your code and don't run in this problem. So i looked at the ASP.NET Forum.

    There is a post RedirectToAction looses session in IIS

    I've just run into this issue. Its not related to redirect to action itself but the app pool. What fixed it for me was deleting the app pool the site was running under in IIS and re-creating it. Works fine now. Source

    0 讨论(0)
  • 2021-01-21 08:56

    Solution:

    Some nutter named the session state cookie name in the web.config and the authentication forms name the same thing.

    <sessionState timeout="20" cookieName="Spacer" />
    
    <forms loginUrl="/spacer/login" name="Spacer" timeout="2200" />
    

    Obviously the effect it was having was trying to store session and cookies in something called the same thing. Im very surprised this just did not blow up.

    Thanks for your help @dknaack, I wouldnt have spotted this so quickly if you were not pointing me in the correct direction.

    0 讨论(0)
提交回复
热议问题