Wrox Programmer Forums
|
BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3
This is the forum to discuss the Wrox book Beginning ASP.NET 3.5: In C# and VB by Imar Spaanjaars; ISBN: 9780470187593
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 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 September 21st, 2008, 06:39 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Appendix B in Beginning ASP.NET 3.5 in VB

Hi! I have enabled SQL Server 2005 Express for remote connections. The PlanetWrox database and ASPNETDB database are attached to SQL Server 2005 Express. Security permissions in the Sql-folder is configured. I have used the SQL Server authentification (Scenario 1), and configured SQL Server security with login and password like it is in the Appendix B. It seems to work out fine so far. I can execute the application and look at pictures in GigPics and also make new accounts that will be stored. Now I want to make it all work with only one database, PlanetWrox (page 702). I run the command
aspnet_regsql -S (local)\SqlExpress -E -A mrp -d PlanetWrox
It is successful, adding following features, membership, profile and rolemanager.
After that, my application still works but how will I proceed to deploy this to a webhost(DASP)? Anyone who knows what next step is?
When I transfer the Sql Database to a web host, is it only the PlanetWrox.mdf and the PlanetWrox log file or is it the aspnetdb files as well? Do I have to change the web.config file that is stored at the web host?
I hope anyone did try this before and have some tips.
Kind regards,
Anders

 
Old September 21st, 2008, 06:53 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
quote:After that, my application still works but how will I proceed to deploy this to a webhost(DASP)? Anyone who knows what next step is?
You know need to move the data to your provider. How you need to do that depends on the provider. Some let you send them the .MDF file and they'll attach it for you. Others allow you to execute CREATE and INSERT statements to recreate the data at the provider. This is explained on page 657 and onwards with the Database Publishing Wizard in particular.
Quote:
quote:When I transfer the Sql Database to a web host, is it only the PlanetWrox.mdf and the PlanetWrox log file or is it the aspnetdb files as well?
The idea of aspnet_regsql is to combine the two databases, so all you need is the PlanetWrox database. Again, whether you can use the MDF or need to create SQL scripts depends on your ISP.
Quote:
quote:Do I have to change the web.config file that is stored at the web host?
Yes, most likely you do. See pages 703 and onwards, Overriding the Connection String and/or Application Settings.

Much of this depends on your ISP, their settings / systems and what they allow / offer you. It's best to contact them and ask for more information. There's a fair chance all of this is in their documentation or FAQs.

Hope this helps,

Imar

---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.
 
Old September 21st, 2008, 11:22 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Imar, I will check this matters with my hosting company.
Regards, Anders

 
Old September 26th, 2008, 09:58 AM
Registered User
 
Join Date: Sep 2008
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Imar,
now the SQL database is working with adding new accounts,photoalbums and pictures but I have a problem with the admin account that worked out fine locally to manage the site. Now it seems to be no manager role anymore. I think that all data get lost when I have attached my local mdf-file to the SQL-database at my host. Is it possible to add user and roles manually directly into the SQL database and where?
Regards,
Anders

 
Old September 27th, 2008, 05:55 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 Anders,

One easy way to do this is to create the users and roles on application start up with the Membership and Roles API. Place the following code in your Global.asax file:
Code:
C#
void Application_Start(object sender, EventArgs e)
{
  // Code that runs on application startup
  if (!Roles.RoleExists("Administrators"))
  {
    Roles.CreateRole("Administrators");
  }

  if (Membership.GetUser("YourUserName") == null)
  {
    Membership.CreateUser("YourUserName", "P4s$w0rd");
  }

  if (!Roles.IsUserInRole("YourUserName", "Administrators"))
  {
    Roles.AddUserToRole("YourUserName", "Administrators");
  }
}

VB.NET
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
  ' Fires when the application is started

  If Not Roles.RoleExists("Administrators") Then
    Roles.CreateRole("Administrators")
  End If

  If Membership.GetUser("YourUserName") Is Nothing Then
    Membership.CreateUser("YourUserName", "P4s$w0rd")
  End If

  If Not Roles.IsUserInRole("YourUserName", "Administrators") Then
    Roles.AddUserToRole("YourUserName", "Administrators")
  End If
End Sub
When the application is started the first time, the user account and role is created (only when they don't exist yet).

Obviously, storing clear text password in text files is a bad idea from a security point of view so be sure to remove this code again once you're done creating the user and role.

Hope this helps,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of Beginning ASP.NET 3.5 : in C# and VB, ASP.NET 2.0 Instant Results and Dreamweaver MX 2004
Want to be my colleague? Then check out this post.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can'T find code to Beginning Asp.net using VB.NET darruler All Other Wrox Books 1 August 12th, 2004 05:04 PM
Help 'beginning asp.net using vb.net' source code jkmf Wrox Book Feedback 1 January 18th, 2004 08:09 AM
Beginning ASP.Net Databases Using VB.Net ISBN 6195 tlamazares SQL Server ASP 1 December 15th, 2003 01:28 PM
Beginning ASP.NET E-Commerce using VB.NET KJ All Other Wrox Books 2 December 2nd, 2003 09:01 AM
Beginning ASP.NET E-commerce with VB.NET attipa All Other Wrox Books 2 June 23rd, 2003 10:35 PM





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