Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 3.5 > ASP.NET 3.5 Basics
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
ASP.NET 3.5 Basics If you are new to ASP or ASP.NET programming with version 3.5, this is the forum to begin asking questions. Please also see the Visual Web Developer 2008 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 3.5 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 3rd, 2010, 09:52 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default Can't Read User.ProviderUserKey

Help please. Thank you.

I get this statement in the watch window:
Because this evaluation could cause side effects, it will not be executed until enabled by user.

Membership.GetUser().UserName does show the name of the logged in user

Code:
Session("loggedinusername") = Membership.GetUser().UserName
Dim User As MembershipUser = Membership.GetUser()
Dim UserKey As GUID = User.ProviderUserKey
  #2 (permalink)  
Old May 3rd, 2010, 10:09 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

GetUser is a method, so the watch window doesn't execute it for you automatically. You have to manually execute / enable it.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old May 3rd, 2010, 10:23 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default The problem is that it's empty in my code

When I breakpoint in my code the value UserKey is empty
There is definitely a value in the Membership DB

Last edited by sg48; May 3rd, 2010 at 10:25 AM..
  #4 (permalink)  
Old May 3rd, 2010, 10:37 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

But what happens when you manually update the value by clicking the refresh icon in the watch window? I thought that's what you meant with "Because this evaluation could cause side effects, it will not be executed until enabled by user."

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #5 (permalink)  
Old May 3rd, 2010, 10:42 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

The value in the watch window shows as Empty when I click the + sign

I think the watch window is not relevant.

In my code when I manually examine the ProviderUserKey it is empty.

My query that uses it as a parameter is failing because of this.

There is a value in the Membership DB and there is a logged in user
  #6 (permalink)  
Old May 3rd, 2010, 10:55 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

This is not about the plus sign, but about the Refresh icon near that message you posted. My guess is that the code is OK, but that the Watch window just doesn't execute it.

What happens when you watch:

Membership,GetUser("UserNameOfUserThatIsLoggdIn")

In other words, how can you be sure there is a logged in user?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #7 (permalink)  
Old May 3rd, 2010, 11:09 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

Because

Session(
"loggedinusername") = Membership.GetUser().UserName

Shows the name of the logged in user
  #8 (permalink)  
Old May 3rd, 2010, 11:28 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Then it has to have a ProviderUserKey as well.

Are you're interpreting the value in the wacth window correctly? Your posts feel a bit crumpy and you're not really supplying a whole lot of information which makes it kind of unattractive to dig into this real deep with you, but my guess is that what you see in the watch window is not what you think you are seeing. Another guess is that entering
Membership.GetUser().ProviderUserKey.ToString() will shed some light on this.

Cheers,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #9 (permalink)  
Old May 3rd, 2010, 11:44 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I do appreciate your help.

I put in an instruction to convert the ProviderUserKey to a string as you suggested and it does show a value. My code is failing when I am filling my dataset.

Code:
ProtectedSub InitSessionVariables()
Session("loggedinusername") = Membership.GetUser().UserName
Dim User As MembershipUser = Membership.GetUser()
Dim UserKey As GUID = User.ProviderUserKey
Dim a AsString = Membership.GetUser().ProviderUserKey.ToString()


Dim Conn AsNew SqlConnection(dsDeals.ConnectionString)


'******************************************
Dim dataSet1 AsNew DataSet()
Dim adapter1 As SqlDataAdapter
Dim CmdGetPersonData AsNew SqlCommand("procGetPersonByUserIDSelect", Conn)

CmdGetPersonData.CommandType = Data.CommandType.StoredProcedure
Dim useridparam AsNew SqlParameter("@userid", SqlDbType.UniqueIdentifier)
useridparam.Value = UserKey
Dim PersonID AsInteger
Dim FName AsString
Dim LName AsString
Conn.Open()
adapter1 = New SqlDataAdapter(CmdGetPersonData)
Try
adapter1.Fill(dataSet1)

My stored procedure is shown below
Code:

ALTER PROCEDURE dbo.procGetPersonByUserIDSelect
(
@userid UniqueIdentifier 

)
AS
SELECT PersonID, FName, LName
FROM tblPerson WHERE userid=@userid
RETURN
  #10 (permalink)  
Old May 3rd, 2010, 11:55 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 54
Thanks: 1
Thanked 0 Times in 0 Posts
Default

I removed my tRy Catch and am getting following error now

Procedure or function 'procGetPersonByUserIDSelect' expects parameter '@userid', which was not supplied.
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create user wizard-check existing user sophia BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 8 January 17th, 2010 07:37 AM
login failed for user Domain\User ID GailCG SQL Server 2005 0 June 29th, 2009 10:45 AM
Read Only Form Is not Read only lryckman Access VBA 3 June 12th, 2007 06:30 AM
login failed for user domain\user babakwx SQL Server 2000 2 May 30th, 2006 12:28 PM
Run DTS with a windows user, not a SQL user Kalli SQL Server DTS 1 September 15th, 2005 11:53 PM



All times are GMT -4. The time now is 10:38 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.