mis_greenwoodhall
asked on
C# ASP.NET Forms Authentication IsInRole Returns False
I have a web site that is acting really strange and I'm not sure where the issue. The website is almost an exact copy of a previous website that still works.
For some reason the IsInRole is returning false even though it shouldn't.
I run this code:
And it actually spits out: System Administrator|False|False
Which makes no sense to me, since I'm basically hard coding it to give out a response of true. For kicks I tested this on my app that works and I got True values. I've tried messing with IIS, scrubbing the Web.Config file and copying from my application that still works fine, and various other things. I'm down to the point where I'll likely end up re-creating the whole thing.
I'm hoping someone can give me a lightbulb as to why the IsInRole is acting up.
For some reason the IsInRole is returning false even though it shouldn't.
I run this code:
FormsIdentity id = (FormsIdentity)HttpContext.Current.User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
// Get the stored user-data, in this case, our roles
string userData = ticket.UserData;
string[] roles = userData.Split(',');
Literal3.Text = roles[0];
// Checking for "System Administrator"
Literal3.Text += "|" + Page.User.IsInRole(roles[0]).ToString();
Literal3.Text += "|" + HttpContext.Current.User.IsInRole(roles[0]).ToString();
And it actually spits out: System Administrator|False|False
Which makes no sense to me, since I'm basically hard coding it to give out a response of true. For kicks I tested this on my app that works and I got True values. I've tried messing with IIS, scrubbing the Web.Config file and copying from my application that still works fine, and various other things. I'm down to the point where I'll likely end up re-creating the whole thing.
I'm hoping someone can give me a lightbulb as to why the IsInRole is acting up.
ASKER
No, they are actually running against different databases.
However, they are running against the same schema and data; one was copied from the other.
However, they are running against the same schema and data; one was copied from the other.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No other solution was offered.
Do you know if both websites are running against the same database?
Thanks,
Richard Hughes