Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2009-07-13
3
Medium Priority
?
281 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 2000 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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

610 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