Search code examples
sqlmembership

MVC4 Membership logging off automatically


I had a project in MVC3 (until today) using SQL compact edition with regular membership forms authentication.

I upgraded it to MVC4 and on the development environment everything is working well. My issue happens when I deploy it to my hosting provider. Basically everyone is getting disconnected every two or three clicks (automatically logged off).

From what I understand looks like the issue is related with the infrastructure that my hosting provider has which is strange since in MVC3 that didn't happen.

So I read on a similar post of a guy complaining the same issue and someone said that he should generate a machine config key and put it on the webconfig. So I did it, however this way I cannot even authenticate anyone, membership returns invalid user/password combination.

Thank you very much for any help


Solution

  • So I was able to figure out why login wasn't working with the new machine config.

    I used this piece of code and I noticed that I need to have the machineKey webconfig entry defined this way :

     validation="HMACSHA256" decryption="Auto"
    

    So right now no one is getting logged off and everyone is able also to login :)

    Thanks