Ask a Question related to ASP.NET Security, Design and Development.
-
Ali Khawaja #1
HttpContext.Current.User not available in the redirected page
I am trying to use Forms Authentication and Role-Based Security:
I have two pages: login.aspx and Default.aspx.
--------------------------
This is what I have in the submit event handler of my login.aspx (it has
an id and pwd fields):
UserDAL user = new UserDAL();
if( user.Authenticate(id,pwd))
{
HttpContext.Current.User = new GenericPrincipal(User.Identity,
user.GetUserRoles(id));
FormsAuthentication.RedirectFromLoginPage(id,false );
}
--------------------------------
Everything works fine uptil here. User is authenticated, and Gets the
proper roles from the db.
The problem is when I redirect to Default.aspx.
I have the following code in the page_load event handler:
private void Page_Load(object sender, System.EventArgs e)
{
string userId = Context.User.Identity.Name;
if(User.IsInRole("SR"))
DisplayAuthorizedLinks(AccessLevel.SR_ALLOWED);
else if(User.IsInRole("CR"))
DisplayAuthorizedLinks(AccessLevel.CR_ALLOWED);
else if(User.IsInRole("FULL"))
DisplayAuthorizedLinks(AccessLevel.FULL_ACCESS);
else if(User.IsInRole("ADMIN"))
DisplayAuthorizedLinks(AccessLevel.ADMIN_ACCESS);
}
At this point, User roles are complete empty. I Can't figure out what is
the case. Seems like context is not being transferred to the other page.
I'll appreciate any help.
Thanks
Ali
Ali Khawaja Guest
-
HttpContext.Current.User.IsInRole
Hi, I have a problem when I am using the HttpContext.Current.User.IsInRole... This is my code: if (HttpContext.Current.User.IsInRole("Admin... -
How secure is HttpContext.Current.User.Identity.Name ?
How secure it is to authorize access to an ASP.NET application based on the value of the HttpContext.Current.User.Identity.Name propery? I... -
creating custom HttpContext.Current.User.Identity
I've started getting into using forms authentication for asp.net apps with c#. From what i understand so far (limited) I like the way things work!... -
Web.HttpContext.Current.User.Identity.Name is blank
I am using an application which is a modification of IBuySpy Portal. It is using Forms authentication. Users login and their name is added to... -
HttpContext.Current.User vs. Thread.CurrentPrincipal
How are HttpConext.Current.User and Thread.CurrentPrincipal different? It seems that they can be set differently in different places. Why would... -
MSFT #2
RE: HttpContext.Current.User not available in the redirected page
Hi Ali,
You may try the way in following article to see if it will work:
HOW TO: Implement Role-Based Security with Forms-Based Authentication in
Your ASP.NET Application by Using Visual C# .NET
[url]http://support.microsoft.com/default.aspx?scid=KB;EN-US;Q311495[/url]
Luke
Microsoft Online Support
Get Secure! [url]www.microsoft.com/security[/url]
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
MSFT Guest



Reply With Quote

