Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 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
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 16th, 2006, 01:58 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Moving App to Hosted site

Hello all,
Love this book! Started dabbling with the Photo Album app of chapter 7. I have made changes to the site and published it to a local folder. I then served it up from my local box and got to it over the Internet...it worked great.

My next step was to put it up on a real hosted site so it would be a bit more permanent. I started by ftp'ing all the files up to my host server. The host maintains SQL Server on a seperate box. I then edited the apps two (2) connection strings to point at the SQL Server (Note: The host has some off-the-shelf ASP.NET 2.0 apps that users can install and modify...I did this with one of thier apps and then went into the web-config and copied the connection string). I then used SQL Server Management Studio Express to copy the Photo and Collection tables from my local install to the hosted SQL Server DB. This appeared to work okay as app did not error out when I brought it up and moved through pages on the site. If connection strings were wrong I assume I would have gotten an error at this point.

All is okay except when I attempt to login to add content from the Upload folder. The application errors out with "Error: 26 Error Locating Server/Instance Specified...". Before I engage the tech support at the host I wondered if someone could tell me if I am missing something fundemental? Do I need to add users / roles or play with anything else in the DB beyond simply adding the tables? Does the app somehow have to be registered with the SQL Server?
Thanks in advance.
Dean


  #2 (permalink)  
Old November 18th, 2006, 11:56 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi Dean,

Glad you like the book.

How does your connectionstring look like now? (When you post it here, make sure to replace any security sensitive information).

It sounds like you're trying to contact a server that doesn't exist.

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #3 (permalink)  
Old November 20th, 2006, 11:48 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I went back and cleaned house in order to start with a clean slate.

Connection strings used by the off-the-shelf application provided by the host is as follows:

<connectionStrings>
<clear/>
<add name="ClubSiteDB" connectionString="server=SQLXXXXXXXXX.shared.hosti ng.local;database=XXXXXX_default;uid=XXXXXX;pwd=XX XXXX; " providerName="System.Data.SqlClient"/>

<add name="LocalSqlServer" connectionString="server=SQLXXXXXXXXX.shared.hosti ng.local;database=XXXXXX_default;uid=XXXXXX;pwd=XX XXXX!;"/>
</connectionStrings>

This site works fine. I noticed that when the site is installed the actual tables used by the site are installed on the SQL server in the DB provided by the host. It does not use the "attachDbFileName" parameter in the connection string. I ignored this and simply tried to use the server name, database name and login credentials within the WROX site's connection string. Thus what the WROX Photo Album connection string was modified to is as follows:

<add name="SqlServerConnectionString" connectionString="server=SQLXXXXXXXXX.shared.hosti ng.local;database=XXXXXX_default;uid=XXXXXX;pwd=XX XXXX;AttachDbFileName=|DataDirectory|PhotoDB.mdf;I ntegrated Security=true;User Instance=true" providerName="System.Data.SqlClient" />

This yields an error as follows:

Server Error in '/128th_photo_gallery' Application.
--------------------------------------------------------------------------------
Invalid value for key 'attachdbfilename'.

If I Google this error message I found the following on a Microsoft forum (http://forums.microsoft.com/MSDN/Sho...35130&SiteID=1):

"This was a bit surprising at first but I finally understand what's happening. When you use AttachDbFileName in conjunction with |DataDirectory| and the Data Source keyword, we enforce that the client machine name is the same as the Data Source machine name. What I'm assuming is happening on your hosters machine is that the Data Source name, whsql-XXXXXXX.mesa1.secureserver.net, is in fact a different name than the ASP.NET Web Server that your pages are being hosted on. We require that the SQL Server is installed on the local box in order to take advantage of |DataDirectory| in your connection string. So in order to use it you'll need to have your hoster provide you access to a Sql Server install (SqlExpress would work) on the same machine. The change Data Source to be equal to the local machine and it will start working. Does this make sense? Can you verify this works for you?
Thanks - ADO.NET Program Manager"

This led me to think I needed to instead create the photo and collection tables within the SQL database on the SQL server itself...though I am not convinced of this yet?

  #4 (permalink)  
Old November 21st, 2006, 02:13 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi there,

Yes, that's pretty much correct. The DataDirectory indeed points to a local folder on the same machine.

So, your other connection strings are necessary. They basically tell your app on what server the database resides, what its name is and how to connect to it.

When you override the localSqlServer string, you basically override the settings for the database used by the provider services like membership. Instead of overriding the localSqlServer connection string, you could also reconfigure the providers. Look in the web.config for the BugBase application for an example.

That said, in your case, XXXXXX_default should have all the aspnet* tables. To make sure they are there, use the aspnet_regsql tool from your Framework installation (%windir%\Microsoft.NET\Framework\v2.0.50727) and create the tables in the database.

From there it should work, although you may still need to add users to the database, like an Admin.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #5 (permalink)  
Old November 22nd, 2006, 01:43 AM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help Imar!

If I understand correctly then I think you are saying that I will need two connection strings, similar to the ones used by the off-the-shelf application provided by the host, in my web.config...Is this correct? I will check the BugBase web.config per your recommendation...I am not clear on what the "LocalSqlServer" string does and/or how it is used.

What exactly does the "aspnet_regsql" tool do? Using the SQL Server Management Studio Express I can check the XXXXXX_default and see that it contains:

dbo.aspnet_Applications
dbo.aspnet_Membership
dbo.aspnet_Paths
dbo.aspnet_PersonalizationAllUsers
dbo.aspnet_PersonalizationPerUser
dbo.aspnet_Profile
dbo.aspnet_Roles
dbo.aspnet_ScemaVersions
dbo.aspnet_Users
dbo.aspnet_UsersInRoles
dbo.aspnet_WebEvent_Events

I am guessing these are the tables you mentioned being required? I will go ahead and reconstruct the Photo and Collection tables in the host database and see where that gets me.
Thanks again for your help...it is appreciated.
Dean
"dthoma128"

  #6 (permalink)  
Old November 25th, 2006, 07:47 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Hi Dean,

Sorry for my late response.

aspnet_regsql is responsible for creating the tables, views and stored procedures in the database for all the ASP.NET provider features.

You may want to take a look here:

http://imar.spaanjaars.com/QuickDocId.aspx?quickdoc=395

and here:

http://weblogs.asp.net/scottgu/archi...25/423703.aspx

for a lot more info about configuring your databases.

The LocalSqlServer connection string is a default connection string, defined in your machine.config file. By default, this connection string tries to attach to a (local)\Express instance of SQL Server. You need to override it (or change the entire configuration for the provider features) if you want to use a different database.

Hope this helps,

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #7 (permalink)  
Old November 30th, 2006, 05:36 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar,
Just wanted to let you know I have made some progress after reading the information on your site as well as Scott's blog. I have had various errors along the way...problems included that I needed to create the stored procedures and the one view in the database...had missed those before. I also had an issue with the apptheme not being found...I ended up having to move the App_Themes folder out from the folder it was in into the root. I also found various issues with where I'd created the tables in the database...specifically the schema. All tables for the off-the-shelf app I had installed earlier were in the "dbo" schema (i.e. dbo.Photo) while the first ones I had instantiated were in a schema of my own username (i.e. deanXXX.Photo). I created a pair in dbo schema and these seem to work. Now I am wrangling with the upload code. I believe this is set-up to pull straight off the server or development workstation somewhere rather than from a remote PC over the Internet. Now that the app is up on a hosted site I will have to reconfigure this. I assume there are two routes I can take...

1. Remove the "upload" capability and simply ftp files to the upload folder and then re-work the addphoto.aspx file to simply make the correct entries into the database.
2. Figure out how to code pulling the files from remote workstations.

Any thoughts on this would be appreciated!
All for now.
Dean

  #8 (permalink)  
Old December 2nd, 2006, 05:08 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

I don't think you need to change much. The PhotoAlbum was designed to be manageable across the Internet with only a web browser.

However, in a hosted environment, there are some things you need to take into account.

First, make sure the Upload folder has read and write permissions. Your ISP can take care of this. They need to grant the access rights to either the ASPNET account or to Network Service.

Then you need to look at the addphoto.aspx file from the secure folder. It tries to save a file to a hard coded path that yo need to adjust:

1. Open addphoto.aspx from the secure folder

2. Scroll down to around line 18 and locate the line that saves the picture.

3. Replace that line with this code:

FileUpload1.SaveAs(System.IO.Path.Combine(Server.MapPath("~/upload"), FileUpload1.FileName))

4. Save and run

The Server.MapPath instruction maps a virtual path to a physical location. So, when your app is located at

C:\inetpub\wwwroot\PhotoAlbum,

pictures are saved at

C:\inetpub\wwwroot\PhotoAlbum\upload

But when your app lives at

\\SomePath\YourAccountName

the pictures are saved at

\\SomePath\YourAccountName\upload

which works in your ISP environment.

Does this help?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #9 (permalink)  
Old December 4th, 2006, 11:03 PM
Authorized User
Points: 51, Level: 1
Points: 51, Level: 1 Points: 51, Level: 1 Points: 51, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2006
Location: Webster, NY, .
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Imar...that did it...thank you. I am now uploading successfully. I had to make one additional modification to the photoID field in the Photo table (had to set the field as the "Identity Specification" so it would auto-increment automatically). Thanks once again!

  #10 (permalink)  
Old December 5th, 2006, 06:21 AM
Imar's Avatar
Wrox Author
Points: 71,804, Level: 100
Points: 71,804, Level: 100 Points: 71,804, Level: 100 Points: 71,804, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,052
Thanks: 80
Thanked 1,581 Times in 1,558 Posts
Default

Really? The default database that comes with the book already has PhotoId as an identity and primary key...

Anyway, is the site live somewhere and publicly available? Would like to see how some of our applications end up on the web....

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


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
Hosted Form of Component angelboy C# 2005 7 March 31st, 2008 02:36 PM
Hosted BeerHouse and sub directory gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 1 January 16th, 2008 01:48 AM
Events with IIS hosted remoting koraykazgan C# 1 May 1st, 2007 03:49 PM
How to point Login tool to hosted database? asp_convert ASP.NET 2.0 Professional 3 February 7th, 2007 04:57 PM
Setting up a Site hosted on a IIS6 in Dreamweaver deanphilpin Dreamweaver (all versions) 1 November 4th, 2003 12:42 PM



All times are GMT -4. The time now is 11:27 PM.


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