0

So, I'm using "old style" ASP.NET roles and auth. I have a custom log in page which redirects based on roles upon login. Works fine... But when I get to the destination page where I need to recheck, it fails. Same user, same role, etc. I've tried both "User.IsInRole" and "Roles.IsUserInRole " with the same result. I've also tried specifically setting cache roles in cookie in my config, nothing works.

As always, I'm deeply indebted for any suggestions!

PaulBinCT2
  • 221
  • 2
  • 14
  • Please post your "recheck" code. – mxmissile Aug 15 '16 at 15:29
  • @mxmissile the most recent is: if (Roles.IsUserInRole("Admin")) { } else { Response.Redirect("/login.aspx"); } Just to check it, and it fails regardless of what I've tried – PaulBinCT2 Aug 15 '16 at 15:37
  • Are you on a web farm, or single server? Web farms will need to have the same machine key in order to decrypt the auth cookie. – Mark W Aug 15 '16 at 15:55
  • @MarkW Just testing so far on my local machine – PaulBinCT2 Aug 15 '16 at 15:58
  • Are you using a custom membership and/or role provider? – Mark W Aug 15 '16 at 16:47
  • @MarkW using the asp,net providers, just the login page is "custom" – PaulBinCT2 Aug 15 '16 at 17:07
  • OK... maybe I've forgotten how this works (very possible), but this is what I got that functions "properly": if (Membership.ValidateUser(nameTest, passwordLogIn.Text)) { FormsAuthentication.Authenticate(nameTest, passwordLogIn.Text); FormsAuthentication.RedirectFromLoginPage(nameTest, rememberMe.Checked); } etc... not what I recall doing in the past but it seems to do the job. – PaulBinCT2 Aug 15 '16 at 17:13
  • @PaulBinCT2 "edit" the question and add relevant code there. Dont add code to the comments. – mxmissile Aug 16 '16 at 14:00
  • @mxmissile thanks, still learning my way around here – PaulBinCT2 Aug 16 '16 at 17:27

0 Answers0