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 June 2nd, 2011, 01:59 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Red face Login Controls

I have years of experience writing .ASP code and am very new to ASP.net programming (like reading your Beginning ASP.NET 4 book is my 1st exposure). I have a question on Login Controls. I have a SQL 2008 database table called tblEmployers that contains what you would call Profile information (details about an employer we are inviting to do a survey and then see calculator values). Part of this table includes an EmployerID (to be used as USERNAME) and a EmployerPassword (created by account manager to be used in the ASP.NET system) prior to the start of the ASP.NET process of showing the survey results. Starting on Page 585 you discuss how the ASP.NET system creates all the different aspnet_* files to use for membership, roles, etc. We predefine the username (EmployerId) and password (EmployerPassword) mainly because we do not want just anyone to login and look at this system. Can I use the data in the tblEmployers to validate the visitors to my site using a Login control and can I save the username for use in my EF as a selection criteria?
 
Old June 3rd, 2011, 05:52 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 there,

Quote:
Can I use the data in the tblEmployers to validate the visitors to my site using a Login control
Yes, but not directly.

By default, the Login controls use ASP.NET Membership which in turn uses a SQL Server provider which in turn expects a specific database schema (tables, views and stored procedures).

You have a few options to work around this:

1. In the Login control, handle the OnLoggingIn event and then access your own database usign custom code. Google or Bing have lots of examples on this.

2. Create your own provider. This is a bit more complex, but offersa great developer experience as you can use all of the Login controls that ship out of the box without writing more custom code (after the provider is built, that is). For some ideas:

http://imar.spaanjaars.com/404/using...rver-providers
http://imar.spaanjaars.com/560/using...under-aspnet-4
http://imar.spaanjaars.com/380/migra...s-and-profiles

Quote:
We predefine the username (EmployerId) and password (EmployerPassword) mainly because we do not want just anyone to login and look at this system.
Even when using the Membership features, you can still predefine users. Just hide the CreateUserWizard behind an Admin login. This is probably the simples way to accomplish things.

Quote:
and can I save the username for use in my EF as a selection criteria?
Yes, you can join your own data on a column such as the user name or user ID.

Hope this helps,

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 June 3rd, 2011, 02:02 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default

Thanks for all the information. After reading several of the posts across the forum I agree with one poster who felt like For now I will try to setup the Membership/Roles and manually add the new users through the management interface.
 
Old June 6th, 2011, 06:31 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Management and Roles

Now that I have figured out how to add Management Roles, etc. to my web application, I have a question on updating this information for the production site. I have this lovely ASPNETDB.MDF file on my local PC where I am doing my development, so how do I get that to update the Management & Roles on my webserver?
 
Old June 7th, 2011, 03:03 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 there,

You need to merge the aspnetdb database structure into yours (using aspnet_regsql.exe), or use a separate database on the remote host as well.

Chapter 19 and Appendix B have more details. In addition you may want to read the following articles to get a better understanding of the different options:

http://weblogs.asp.net/scottgu/archi...-database.aspx
http://weblogs.asp.net/scottgu/archi...nt-part-1.aspx
http://weblogs.asp.net/scottgu/archi...25/423703.aspx

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 June 7th, 2011, 01:53 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Question Concerns for older version of SQL

Thanks for the articles to read on deploying the ASPNETDB.MDF database files. Do need to be concerned that all the examples you directed me to refer to SQL 2005 or earlier? I have a brand spanking new server running Windows Server 2008 R2 and SQL Server 2008. Are these tools compatible with this server setup? I must have run a utility at some point in my experimenting that created the tables on my webserver that are contained in the ASPNETDB.MDF file on my local pc. When I look at the tables in my webserver Calculator DB, I see tables like dbo.aspnet_Applications, dbo.aspnet_Membership, dbo.aspnet_Paths, etc.
 
Old June 7th, 2011, 02:02 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Publishing to Webserver

I guess I should have read Chapter 19 more closely before posting last thread. In VS2010, the Database Publishing Wizard in included. Will read Chapter 19 and experiment more. Thanks for your help.
 
Old June 7th, 2011, 04:08 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Publishing to Webserver

clicked twice. bad mouse/fingers!
 
Old June 7th, 2011, 04:45 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Btw, all the aspnet* objects (tables, views and stored procedures) have probably been generated when the aspnetdb database was created the first time. Asp.net has built-capabilities to create the database and the necessary database objects the first time you use the Application Services without an existing database.

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 June 8th, 2011, 01:19 PM
Authorized User
Points: 84, Level: 1
Points: 84, Level: 1 Points: 84, Level: 1 Points: 84, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
Default Using Username from Login Control

I think I have my Login controls all set. I can now login with a Username and Password that validates with ASPNETDB* built-in functionality of VS2010 and ASP.net 4. My question now is: Does the Username persist now that I am logged in and can I use that to select data for an Entity Framework page? I have created a EF Model called CALC that has two linked tables (Employer & Summary). What I want to be able to do is take the Username and select the Summary record that matches, perform some calculations based on values from the record and display them. Seems pretty easy but I am having troubles wrapping my head around how the .NET does this.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using basic login controls jgtech BOOK: Beginning ASP.NET 4 : in C# and VB 3 October 28th, 2010 02:38 AM
The Login Controls HovhannesGo BOOK: Beginning ASP.NET 4 : in C# and VB 3 September 17th, 2010 07:59 AM
Login controls : Way to customize them ? Rushino BOOK: Beginning ASP.NET 4 : in C# and VB 2 May 15th, 2010 01:07 PM
Problem regarding Login controls bond007 ASP.NET 2.0 Basics 1 April 16th, 2009 01:14 AM
Login Controls mashype ASP.NET 3.5 Basics 4 January 26th, 2009 03:07 PM





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