[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

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

Posted on 2012-09-14
3
Medium Priority
?
329 Views
Last Modified: 2012-09-25
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.
0
Comment
Question by:sbornstein2
3 Comments
 
LVL 26

Accepted Solution

by:
Alan Warren earned 800 total points
ID: 38400901
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
 
LVL 23

Expert Comment

by:Roopesh Reddy
ID: 38401949
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
 

Author Closing Comment

by:sbornstein2
ID: 38432587
thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question