Another Object Reference

  • Thread starter Thread starter BW
  • Start date Start date
B

BW

Using Asp.net 2.0.

All I want is to Get the current username and display it in a welcome
message. I'm getting the following error:
Error: Object reference not set to an instance of an object. Source:
nfy0vvzn Trace: at Default1_aspx.Page_Load(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\Aws\Default1.aspx.vb:line 10


Here's the code:

Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Load
Dim mUser As MembershipUser

Try

mUser = Membership.GetUser(True)

Label1.Text = "Welcome " & mUser.UserName & " to blah, blah, blah" 'ERROR
HAPPENS HERE

Catch ex As Exception

Label1.Text = "Error: " & ex.Message & " Source: " & ex.Source & " Trace: "
& ex.StackTrace

End Try

End Sub

Any suggestions?

Bernard
 
Membership.GetUser() is returning null - probably means the account was not
found.

-- bruce (sqlwork.com)


| Using Asp.net 2.0.
|
| All I want is to Get the current username and display it in a welcome
| message. I'm getting the following error:
| Error: Object reference not set to an instance of an object. Source:
| nfy0vvzn Trace: at Default1_aspx.Page_Load(Object sender, EventArgs e) in
| C:\Inetpub\wwwroot\Aws\Default1.aspx.vb:line 10
|
|
| Here's the code:
|
| Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles
| Me.Load
| Dim mUser As MembershipUser
|
| Try
|
| mUser = Membership.GetUser(True)
|
| Label1.Text = "Welcome " & mUser.UserName & " to blah, blah, blah"
'ERROR
| HAPPENS HERE
|
| Catch ex As Exception
|
| Label1.Text = "Error: " & ex.Message & " Source: " & ex.Source & " Trace:
"
| & ex.StackTrace
|
| End Try
|
| End Sub
|
| Any suggestions?
|
| Bernard
|
|
 
You're right. The object is not returning a user. Problem is it should be.
The user logs in, then is directed to this page.

Thanks again,

Bernard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top