Forms Authentication App - Need User Identity from the start Help!

Hello all,

I have an app that uses forms auth that was working fine on my localhost but of course when I place it out on IIS no dice.   I have a home page the user hits in the site under the root where the web.config lives as well of course that uses forms auth.  In the home page I need to check if the user is a certain type then redirect based on if they are.  I was trying to use:

Request.ServerVariables["LOGON_USER"]

But that does not work of course it's empty.  So how can I do this either off a global.asax session start or whatever I need to do.  I am really hoping I don't have to pull out the redirect pages and code from this main app as I want it to live there.  I somehow need the user identity.
sbornstein2Asked:
Who is Participating?
 
Alan WarrenConnect With a Mentor Applications DeveloperCommented:
If you are using <authentication mode="Forms"> in your web.config and your connectionstring is defined in your web.config and your connectionstring is valid (the db exists on the server) then, you should be able to get the UserName from the membership provider in a few different ways.

Dim username As String = My.User.Name
Dim username As String = HttpContext.Current.User.Identity.Name
Dim username As String = Page.User.Identity.Name

' The second one is probably the most robust.

Open in new window

Regarding the "user being a certain type", I suspect membership roles would be the go:
Examining ASP.NET's Membership, Roles, and Profile - Part 1

Alan
0
 
Roopesh ReddyIT AnalystCommented:
Hi,

Context.User.Identity.Name should solve your problem!

Check the MSDN article - http://msdn.microsoft.com/en-us/library/xdt4thhy(v=vs.100).aspx

Hope it helps u...
0
 
sbornstein2Author Commented:
thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.