Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning ASP.NET 4 : in C# and VB
This is the forum to discuss the Wrox book Beginning ASP.NET 4: in C# and VB by Imar Spaanjaars; ISBN: 9780470502211
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 4 : in C# and VB section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old December 15th, 2011, 12:48 PM
Authorized User
Points: 194, Level: 3
Points: 194, Level: 3 Points: 194, Level: 3 Points: 194, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default Extending ASPNETDB

Hi Imar,

Thank you very much for your time in this forum.

In the book I saw that you used the UserName from the ASPNETDB database. Now I have a database that has a Customer, an Address, an Appointment, and a Staff table. I want to create a relationship between my tables (Customer and Staff) and the aspnet_Users and aspnet_Membership tables.

What I want to do is have a UserID column in each of my tables as a foreign key to those two aspnetdb tables.

The thing is I want to collect more information like contactNo, address, etc from the customers and I want to be able to query the tables and return a single value.

The thig is I do not see any way in the System.Web.Security namespace to access the UserID from those tables.

Is there another way or can a relationship be made between those tables?
Reply With Quote
  #2 (permalink)  
Old December 16th, 2011, 04:10 PM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi there,
Quote:
The thig is I do not see any way in the System.Web.Security namespace to access the UserID from those tables.
Not sure what you mean with this. You can get the user name from User.Identity as explained in the book, which you can then use to query your own tables. If that's not what you mean, can you elaborate on what you're looking for?

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!
Reply With Quote
  #3 (permalink)  
Old December 16th, 2011, 05:51 PM
Authorized User
Points: 194, Level: 3
Points: 194, Level: 3 Points: 194, Level: 3 Points: 194, Level: 3
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2011
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Imar,

Thank you for responding to my post. What I meant is that in the book, you used the UserName.What I want to do is put a UserId column in my table as the foreign key and create a relationship between my table and the aspnetdb users or membership table.

Is it advisable?

Second, how do I get the UserId when the user signs up. I am using the hand coded method and the EF model.
Thank you once again...

Last edited by malie22001; December 16th, 2011 at 05:54 PM..
Reply With Quote
  #4 (permalink)  
Old December 17th, 2011, 05:21 AM
Imar's Avatar
Wrox Author
Points: 72,038, Level: 100
Points: 72,038, Level: 100 Points: 72,038, Level: 100 Points: 72,038, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,080
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi malie22001,

There are a few ways to uniquely identify a Membership user. The official recommendation by Microsoft is to use a combination of the UserName and the application name (which you set in the web.config file on the Membership and other configuration elements). You should store both in your custom tables.

As an alternative, you can store the user's unique ID, a GUID in the case of the standard SqlMembershipProvider, which you can get by calling Membership.GetUser().ProviderUserKey.

Microsoft recomends against using the ProviderUserKey as its internal implementaton which *might* change in the future. However, it hasn't changed since the first release of Membership so you're probably safe if you use 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!
Reply With Quote
Reply


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
Extending the Properties Window ? vsny BOOK: Professional Visual Studio 2008 ISBN: 978-0-470-22988-0 0 February 27th, 2010 01:36 PM
Extending the CMS retroviz BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 0 April 23rd, 2008 07:00 AM
extending xslt RoeZ XSLT 3 February 28th, 2008 05:52 PM
Extending DataGridItem Phrozen ASP.NET 2.0 Professional 0 March 11th, 2007 09:17 AM
classes extending and inheriting jlong Beginning PHP 2 July 7th, 2003 02:32 PM



All times are GMT -4. The time now is 08:00 PM.


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