Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ASP.NET 4.5 how to get login user name

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have this from ASP.NET 4.0 which works great, using Visual WEB developer Express.
However in Vis Studio 2012 Pro, get error on yellow line
Object reference not set to an instance of an object.
I want to get the user name and also send them to a area/page which is used for authenticate user.
I have looked for several days to figure this out and have gotten nothing.
Code:
   Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' Fires when the application is started
        BundleConfig.RegisterBundles(BundleTable.Bundles)
        AuthConfig.RegisterOpenAuth()
        [highlight #FCE94F]If User.Identity.Name <> "" Then[/highlight]
            Session("UserName") = User.Identity.Name
        Else
            Session("UserName") = "DEMO"
        End If
    End Sub
[code]


DougP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top