Wrox Programmer Forums
|
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 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
 
Old December 15th, 2011, 12:48 PM
Authorized User
 
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?
 
Old December 16th, 2011, 04:10 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
Old December 16th, 2011, 05:51 PM
Authorized User
 
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..
 
Old December 17th, 2011, 05:21 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!





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





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