3

I'm using the ASP.NET MVC SimpleMemberShip Provider,

There isn't any problem for a while after I logged in. I check if user is Boss, this is working.

if (User.IsInRole("Boss")) {
 //do something
}

But after a few minutes when I refresh the page ,User.IsInRole("Boss") always returns false. I debugged and checked if user still logged in, yes, user is still there, nothing changed but IsInRole keeps returning false.

When I log out and log in again It starts working.

I think the problem is about Sessions but I couldn't find any solution.

This is what I have in Web.config

<authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>

UPDATE:

I realized that happens when I rebuild my project.

Okan Kocyigit
  • 13,203
  • 18
  • 70
  • 129

1 Answers1

0

You could be losing your cookie. Try adding: <forms loginUrl="~/Account/Login" cookieless="UseCookies" timeout="2880" />

this solved quite a few problems in our MVC app.

JusMe
  • 278
  • 1
  • 7