B
Brad Farrell
If anyone can help on this, I would appreciate it.
Got a website and I'm trying to protect a portion of it under a subfolder
called "Protected"
In my web.config file I have the following for the authorization tag.
Authentication is set to forms and pointing to my login.aspx page.
<location path="Protected">
<system.web>
<authorization>
<allow roles="admin"/>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
In my login.aspx.cs file, I match the user credentials up with the database
and run the following:
FormsAuthentication.Initialize();
String strRole = AssignRoles(customerId); "Returns my admin role"
FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1,customerId,
DateTime.Now,DateTime.Now.AddMinutes(20),RememberLogin.Checked,strRole,
FormsAuthentication.FormsCookiePath);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(fat)));
Response.Redirect(FormsAuthentication.GetRedirectUrl(customerId,
RememberLogin.Checked));
In my header portion, I am trying to hide/show a menu option using the
following:
Admin.Visible = Page.User.IsInRole("admin");
The role comes back from the database as admin, but the
Page.User.IsInRole("admin") is returning a false result. Any ideas?
Got a website and I'm trying to protect a portion of it under a subfolder
called "Protected"
In my web.config file I have the following for the authorization tag.
Authentication is set to forms and pointing to my login.aspx page.
<location path="Protected">
<system.web>
<authorization>
<allow roles="admin"/>
<allow roles="Admin"/>
<deny users="*"/>
</authorization>
</system.web>
</location>
In my login.aspx.cs file, I match the user credentials up with the database
and run the following:
FormsAuthentication.Initialize();
String strRole = AssignRoles(customerId); "Returns my admin role"
FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1,customerId,
DateTime.Now,DateTime.Now.AddMinutes(20),RememberLogin.Checked,strRole,
FormsAuthentication.FormsCookiePath);
Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName,
FormsAuthentication.Encrypt(fat)));
Response.Redirect(FormsAuthentication.GetRedirectUrl(customerId,
RememberLogin.Checked));
In my header portion, I am trying to hide/show a menu option using the
following:
Admin.Visible = Page.User.IsInRole("admin");
The role comes back from the database as admin, but the
Page.User.IsInRole("admin") is returning a false result. Any ideas?