Solved

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

Posted on 2009-07-13
3
276 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

Independent Software Vendors: 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

Suggested Solutions

Title # Comments Views Activity
Modal Popup Extender control 1 51
Where is this file? 3 33
disable data migrations in visual studio 2017 4 42
Asp.Net Session Question 2 33
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

740 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