Solved

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

Posted on 2009-07-13
3
278 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 10

Accepted Solution

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

Author Comment

by:spaceneedlejumper
ID: 24843053
Thank you!
0
 

Author Closing Comment

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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …

705 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