 |
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
|
|
|
|
|

June 2nd, 2011, 01:59 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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?
|
|

June 3rd, 2011, 05:52 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 3rd, 2011, 02:02 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 6th, 2011, 06:31 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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? 
|
|

June 7th, 2011, 01:53 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 7th, 2011, 02:02 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|
|

June 7th, 2011, 04:08 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
Publishing to Webserver
clicked twice. bad mouse/fingers!
|
|

June 7th, 2011, 04:45 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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
|
|

June 8th, 2011, 01:19 PM
|
|
Authorized User
|
|
Join Date: May 2011
Posts: 19
Thanks: 3
Thanked 0 Times in 0 Posts
|
|
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.
|
|
 |
|