jtuttle99
asked on
Asp.net logged in another membership provider get null error
If I log in different membership provider, and go to page that contains following code, I get NullReferenceException error. User will be authenticated even if I loggin to different membership.
Is there any ways to prevent from getting error??
If User.Identity.IsAuthentica ted Then
Dim UserIdentity As MembershipUser = Membership.Providers("Cust Membership Provider") .GetUser(H ttpContext .Current.U ser.Identi ty.Name, False)
Dim currentUserID As String = UserIdentity.ProviderUserK ey.ToStrin g()
Is there any ways to prevent from getting error??
If User.Identity.IsAuthentica
Dim UserIdentity As MembershipUser = Membership.Providers("Cust
Dim currentUserID As String = UserIdentity.ProviderUserK
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Here is my situation. I have membership providers for employee(for maintain contents) and customer.
Customer can't go to employee page, because admin side is protected by roles.
Log in page is only allowed to log in employee log in.
So, the problem is that if employee goes to some customer's side of the web site, this null error happens.
Employee status seem to be authenticated (by employee membership provider), so it passes "If User.Identity.IsAuthentica ted then"
I would like to know how to escape these codes if user is logged in to employee membership provider.
something like this...
If userlogged in employee membership provider then...
Anyone??
Customer can't go to employee page, because admin side is protected by roles.
Log in page is only allowed to log in employee log in.
So, the problem is that if employee goes to some customer's side of the web site, this null error happens.
Employee status seem to be authenticated (by employee membership provider), so it passes "If User.Identity.IsAuthentica
I would like to know how to escape these codes if user is logged in to employee membership provider.
something like this...
If userlogged in employee membership provider then...
Anyone??
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The code works, but when I logged in correct membership provider, I'm also kicked out of the page.
There are two things that I want to achieve.
1. check if user is authenticated or not
2. if so, check user is logged in correct membership provider
Are there any ways to check if I logged in right membership provider?
Thank you for your help!