Solved

Why can't I use User.Identity.Name on a .master.vb file?

Posted on 2009-07-13
3
271 Views
Last Modified: 2012-05-07
I am making a job board for the college I attend.

When an employer first creates their account I need to have them fill in their profile as the first thing they do.  Creating a profile gives them an Employer ID from the database.  I need this in order to prevent them from creating a Job without first having an Employer ID which causes problems.

In order to do this I am disabling some links on the employer.master file based on the raw URL of the user.  Disabling links is no problem except for the fact that I need to have one enabled, the "Contact us for help" link.  If the new employer clicks this link, I need to check if they have already filled a profile and gotten their ID from the database (because this link is also available everywhere else in the site).  If they have not, I need to maintain the disabled status of the links previously disabled.

My idea was to use code like the following which works fine on other pages in the site for determining who the user is.

After executing that code I would check to see if Session("Emp_UserLogin") has a value.  If not, disable the links.

Any ideas?
Session("Emp_UserLogin") = User.Identity.Name
 

        Dim myConnectionString As String = "Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\CAC.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True"

        Using myConnection As New SqlConnection(myConnectionString)

            Dim myCommand As New SqlCommand()

            myCommand.Connection = myConnection

            myCommand.CommandText = "SELECT [EmpID] FROM [Employer] WHERE ([Emp_UserLogin] = '" & Session("Emp_UserLogin") & "')"

            myConnection.Open()

            Session("EmpID") = myCommand.ExecuteScalar()

        End Using

Open in new window

0
Comment
Question by:spaceneedlejumper
  • 2
3 Comments
 
LVL 10

Accepted Solution

by:
Espavo earned 500 total points
Comment Utility
Use:
Session("Emp_UserLogin") = Page.User.Identity.Name
0
 

Author Comment

by:spaceneedlejumper
Comment Utility
Thank you!
0
 

Author Closing Comment

by:spaceneedlejumper
Comment Utility
I think I had this problem before when I wasn't paying for this service :)=
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

762 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now