Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Security > Need help with Login Control

Reply
Thread Tools

Need help with Login Control

 
 
Learner
Guest
Posts: n/a
 
      07-20-2006
Hello,

I am trying to get the UserID from the aspnet_users from aspnetdb
database with the below code snippet.



Protected

Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Login1.LoggedIn

Dim UserID As String = String.Empty

Dim ManufacturerID As Integer
UserID =
Membership.GetUser(Page.User.Identity.Name).Provid erUserKey.ToString


Dim BL As New GroundingBL
ManufacturerID = BL.GetManufacturerIDFromUsers(UserID)


End Sub


As you see I am using Login1_LoggedIn event, to me, that means the user
is already logged in. But for some reason the value of
page.User.Identity.Name is empyt ("") when I debug. Am I using the
wrong event here? When I debug all through I get the below error

************************************************** ***********

System.NullReferenceException was unhandled by user code
Message="Object reference not set to an instance of an object."
Source="App_Web_drkvx8xw"
StackTrace:
at UnSecured_MainLogin.Login1_LoggedIn(Object sender, EventArgs
e) in
D:\VSProjects\GroundingDemo\GroundingDemo\UnSecure d\MainLogin.aspx.vb:line
16
at System.Web.UI.WebControls.Login.OnLoggedIn(EventAr gs e)
at System.Web.UI.WebControls.Login.AttemptLogin()
at System.Web.UI.WebControls.Login.OnBubbleEvent(Obje ct source,
EventArgs e)
at System.Web.UI.Control.RaiseBubbleEvent(Object source,
EventArgs args)
at System.Web.UI.WebControls.Button.OnCommand(Command EventArgs
e)
at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
eventArgument)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean
includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


************************************************** **************

I need the UserID value and should put in a session variable and should
be used to pull other data values in our database based on this UserID
value.

Could some one please help me here and suggest me the right event that
fires off after user completely logged in.



Thanks

-L

 
Reply With Quote
 
 
 
 
Ron
Guest
Posts: n/a
 
      07-21-2006
For on your ManufactureID is an Int value.
And the UserId of the aspnet_Users table is a Guid();

But to get that value form the table you have to do the following.

Try this.

Guid userID = new Guid();
userID = (Guid)Membership.GetUser(_userName).ProviderUserKe y;


string someId = userID.ToString();

Of course this is in C# so you will have to convert to VB

Hope this helps.
Ron


"Learner" wrote:

> Hello,
>
> I am trying to get the UserID from the aspnet_users from aspnetdb
> database with the below code snippet.
>
>
>
> Protected
>
> Sub Login1_LoggedIn(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles Login1.LoggedIn
>
> Dim UserID As String = String.Empty
>
> Dim ManufacturerID As Integer
> UserID =
> Membership.GetUser(Page.User.Identity.Name).Provid erUserKey.ToString
>
>
> Dim BL As New GroundingBL
> ManufacturerID = BL.GetManufacturerIDFromUsers(UserID)
>
>
> End Sub
>
>
> As you see I am using Login1_LoggedIn event, to me, that means the user
> is already logged in. But for some reason the value of
> page.User.Identity.Name is empyt ("") when I debug. Am I using the
> wrong event here? When I debug all through I get the below error
>
> ************************************************** ***********
>
> System.NullReferenceException was unhandled by user code
> Message="Object reference not set to an instance of an object."
> Source="App_Web_drkvx8xw"
> StackTrace:
> at UnSecured_MainLogin.Login1_LoggedIn(Object sender, EventArgs
> e) in
> D:\VSProjects\GroundingDemo\GroundingDemo\UnSecure d\MainLogin.aspx.vb:line
> 16
> at System.Web.UI.WebControls.Login.OnLoggedIn(EventAr gs e)
> at System.Web.UI.WebControls.Login.AttemptLogin()
> at System.Web.UI.WebControls.Login.OnBubbleEvent(Obje ct source,
> EventArgs e)
> at System.Web.UI.Control.RaiseBubbleEvent(Object source,
> EventArgs args)
> at System.Web.UI.WebControls.Button.OnCommand(Command EventArgs
> e)
> at System.Web.UI.WebControls.Button.RaisePostBackEven t(String
> eventArgument)
> at
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument)
> at System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument)
> at System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection
> postData)
> at System.Web.UI.Page.ProcessRequestMain(Boolean
> includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
>
>
> ************************************************** **************
>
> I need the UserID value and should put in a session variable and should
> be used to pull other data values in our database based on this UserID
> value.
>
> Could some one please help me here and suggest me the right event that
> fires off after user completely logged in.
>
>
>
> Thanks
>
> -L
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Login control. In prod server, Need to attach App_Data mdffiles to database. Help. aboutjav.com@gmail.com ASP .Net 0 02-28-2008 11:41 PM
Can't create simple login page using asp:login control Sasquatch ASP .Net 2 10-03-2006 09:22 PM
Can login with Login Control ad ASP .Net 9 08-31-2006 05:46 PM
Keep getting "Your login attempt was not successful...." from <asp:Login> control - but it works on Dev box. Jack ASP .Net Web Controls 1 07-16-2006 06:08 AM
How to center login button in Login control? ike2010 ASP .Net 0 11-15-2005 09:13 PM



Advertisments