HttpContext.Current.User.IsInRole

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
In my asp.net app I am using this code:

FormsAuthenticationTicket ticket =
new FormsAuthenticationTicket(
1,
lcred.UserName,
DateTime.Now,
DateTime.Now.AddMinutes(ldExpiration),
false,
lsRoles
);

lsRoles is a string with all roles (separated with "|").

When I later use the HttpContext.Current.User.IsInRole method it works fine
on my developer machine but not on my production machine... what can be wrong.

Thanks
 
From what you've shown us, you aren't doing enough to get it work (not sure
why it's working in dev).

Take a look at:
http://www.codeproject.com/aspnet/AspNetCustomAuth.asp

But you should be getting the roles (from the cookie if they are there, or
from wherever else if they aren't) and creating a new IPrincipal user which
you assign to the Context.User.

Karl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top