Search code examples
asp.net-mvcasp.net-mvc-3authenticationasp.net-membershipcustom-membershipprovider

ASP.NET MVC3 login not for long


I am using own membership provider and I can login and logout. When I login, it is been login just for a moment and then no user is login. I don´t know where is problem but when I am trying it on my computer (IIS Express) the user is login for long time but when I upload my website to my hosting provider then the user is login just for several seconds. Thanks for help


Solution

  • If the application runs in a web farm you must ensure that all nodes of this web farm have the same machineKey. If they do not have the same machine keys if the authentication cookie is emitted on server 1, and the next request is served by server 2 it won't be able to decrypt this cookie. You could try setting their value in the web.config of your application.