Move local ASP.NET website based on MS Small business starter kit to Godaddy.com hosting

2008-04-30


I create an ASP.NET 2.0 small website for a company based on Microsoft  Small Business Starter Kit recently.

I added administration module, login module and other new module the customer required. When I finished, Everything work well on my local PC. Later the customer bought a Godaddy.com share hosting space and I have to deploy the website to his godaddy space.

Since I developed this small website on SQL Server 2005 Express and MS Visual studio 2005 professional edition. I met a big problem : How to move the data from SQL Server 2005 Express to Godaddy's SQL Server 2005 (I am lucky this time, Godaddy provides SQL Server 2005 since 2007 or the end of 2006, I bought its hosting in the beginning of 2006, it was only SQL Server 2000 and only there is ONE SQL server DB that customer can use).

Finally I deploy successfully. I write down all the processing that I did for this small website (www.HKNConsulting.com):

1: use sql server 2005 management express to general SQL Scripit (get empty tables and asp.net security tables, views,

store precedure), get a .sql file; (godaddy provides SQl Server 2005 now)

2: remove all "--" comment line from .sql file (godaddy's SQl control panel doesn't recognize "--" comment sign);

3: copy all sql script to godaddy's sql server control panel and run;

4: insert some initial data to asp.net 2.0 tables:

SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('common', 1, 1)

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('health monitoring', 1, 1)

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('membership', 1, 1)

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('personalization', 1, 1)

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('profile', 1, 1)

INSERT INTO [aspnet_SchemaVersions]([Feature], [CompatibleSchemaVersion], [IsCurrentVersion]) VALUES('role manager', 1, 1)

Go

5: modify web.config to give correct connect string:

<add name="MFSQLConnectionString" connectionString="Server=p3swhsql-vxx.xxx.xxx.secureserver.net; Database=DB_<XXXXXX>; User ID=<XXXXX>; Password=<XXXX>; Trusted_Connection=False" providerName="System.Data.SqlClient" />

**6: **make sure in your web.config , there are some configration for asp.net 2.0 membership due to your own database (combine

the asp.net 2.0 membership database -- normally it is ASPNETDB.mdf, to your own database):

<membership> <providers> <remove name="AspNetSqlMembershipProvider"/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider, System.Web, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a" connectionStringName="MFSQLConnectionString" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="true" applicationName="/" requiresUniqueEmail="false" passwordFormat="Hashed" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" passwordStrengthRegularExpression=""/> </providers> </membership> <profile> <providers> <remove name="AspNetSqlProfileProvider"/> <add name="AspNetSqlProfileProvider" connectionStringName="MFSQLConnectionString" applicationName="/" type="System.Web.Profile.SqlProfileProvider, System.Web, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"/> </providers> </profile> <roleManager enabled="true"> <providers> <remove name="AspNetSqlRoleProvider"/> <add name="AspNetSqlRoleProvider" connectionStringName="MFSQLConnectionString" applicationName="/" type="System.Web.Security.SqlRoleProvider, System.Web, Version=2.0.0.0, Culture=neutral,

PublicKeyToken=b03f5f7f11d50a3a"/> </providers> </roleManager>

7: Remove "  <customErrors mode="RemoteOnly" defaultRedirect="CustomError.aspx"> from web.config file; Add "<customErrors mode="Off"/>";

8: Insert your own data to your user tables:

INSERT INTO [Services]([visible], [title], [Category],[description]) VALUES(True, 'Expertise on business', 'Business','•    Governments and public sectors •    Banking business •    Mutual funds investments •    Group Pensions •    Insurance ')

INSERT INTO [Services]([visible], [title], [Category],[description]) VALUES(True, 'Expertise on Information Technologys', 'IT','•    e-Solutions using latest web technology •    Infrastructure architecture •    Enterprise Technology Assessments ')

INSERT INTO [Services]([visible], [title], [Category],[description]) VALUES(True, 'Business Analysis', 'IT','•    Strategic planning •    Business case development •    Preliminary analysis and needs identification •    Business requirement development •    Business process development and re-design ')

INSERT INTO [Services]([visible], [title], [Category],[description]) VALUES(True, 'System Design and Development', 'IT','•    Project Management •    Requirements definition •    System requirements definition •    System architecture •    Data and process analysis •    Development and Implementation •    Quality assurance and user acceptance testing •    Documentation ')

INSERT INTO [Staff]([visible], [firstName],[lastName],[title],[description]) VALUES(True, 'Wayne', 'Nguyen','Senior Team Manager','Wayne is a partner with HKN Consulting and supports the Ontario

Public Sector Practices.   Wayne brings over 15 years of financing industry and consulting experience both in the private

and public sectors.  Wayne has built a great deal of knowledge and experience in e-Government and e-Business through

managing projects for many major financing clients from agencies under Ontario Ministry of Finance, Ministry of Municipal

Affairs and Housing, to banking, investments, and insurance companies.  His extensive experience of back-end and web-based

technology as well as indepth knowledge in business processes and practices within and across organizations help him in

achieving high quality results for clients.

Prior to doing consulting, Wayne was project manager and technical lead for several companies, including Barclays Bank

(U.K.), Fidelity Investments (U.S.) , and Canada Life.  He holds a Master degree in Computer Science.')

INSERT INTO [Staff]([visible], [firstName],[lastName],[title],[description]) VALUES(True, 'Professional', 'Team','Professional Team','Our professional team consists of dedicated, highly trained and

experienced individuals:

•    Project managers •    Applications architects •    Business analysts •    Quality assurance analysts •    Systems analysts •    Database analysts •    Developers ')

INSERT INTO [Images]([fileName], [path],[imgClass]) VALUES('POINT.GIF', 'images\staff','STAFF')

INSERT INTO [Images]([fileName], [path],[imgClass]) VALUES('2190.jpg', 'images\services','SERVICE')

(Note: if you insert images into Image Table, you must check whether these images existing the related folder)

9: Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the

following specific error details and modify your source code appropriately.

Compiler Error Message: CS0433: The type 'Staff' exists in both 'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary

ASP.NET Files\root\799f60bd\464de44c\assembly\dl3\058d1167\5ec0b38b_b386c701\App_Web_75ma_t_n.DLL' and

'c:\windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET

Files\root\799f60bd\464de44c\assembly\dl3\22c56c35\5400338b_b386c701\App_Code.DLL'

Cause:

I used the same name "Staff" for one aspx page and one class, this lead Type name conflict when compile, but it can work on

my local PC not only on Godaddy remote hosting, Finally I give the class name a new name "StaffType" , then it is OK.

10:

Unable to cast object of type 'System.DBNull' to type 'System.String'. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace

for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Unable to cast object of type 'System.DBNull' to type 'System.String'.

Source Error:

Line 41:                         <asp:TemplateField> Line 42:                             <ItemTemplate> Line 43:                                 <asp:Image ID="Image2" runat="server" ImageUrl='<%# (string)Eval(@"imageUrl") +

(string)Eval(@"imgFileName") %>' Line 44:                                     AlternateText='<%# (string)Eval("imageAltText")%>' Width="120" Height="90"

CssClass="photo-border photo-float-left" /> Line 45:                                 <h2> Reason:

imageAltText field is Null. strange it work on Local but No work on Godaddy.com , just like 9 above.

Resolve:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSource1" AllowPaging="True" PageSize="5" OnRowCreated="GridView1_RowCreated" BorderWidth="0px" BorderColor="White" DataKeyNames="serviceID"> <Columns> <asp:TemplateField> <ItemTemplate> <asp:Image ID="Image2" runat="server" ImageUrl='<%# ((Eval("imageUrl") is DBNull)?String.Empty:(string)(Eval(@"imageUrl"))) + ((Eval("imgFileName") is DBNull)?String.Empty:(string)(Eval(@"imgFileName"))) %>' AlternateText='<%# ((Eval("imageAltText") is DBNull)?String.Empty:(string)(Eval("imageAltText"))) %>' Width="120" Height="90" CssClass="photo-border photo-float-left" /> <h2> <asp:LinkButton ID="LinkButton1"  CommandName= "Select" CommandArgument='<%#"Id"%>' runat="server" OnCommand="LinkButton1_OnCommand"> <%# Eval("title").ToString()%> </asp:LinkButton></h2> <p> <%# Eval("description").ToString().PadRight(256,' ').Substring(0, 256) %> </p> <asp:ImageButton ID="ImageButton1" CommandName="Select" CommandArgument='<%#"Id"%>' runat="server" OnCommand="LinkButton1_OnCommand" ImageUrl="images/arrow.gif" /> <asp:LinkButton ID="LinkButtonNews" CommandName="Select" CommandArgument='<%#"Id"%>' runat="server" OnCommand="LinkButton1_OnCommand">Read More </asp:LinkButton> <hr /> </ItemTemplate> </asp:TemplateField> </Columns> <PagerSettings Mode="NumericFirstLast" Position="TopAndBottom" /> </asp:GridView>

11:

Administraton : When tried to upload image file, get the following error:

ERROR: Access to the path 'd:\hosting\waynenguyen\images\staff\Blue hills.jpg' is denied.

Reason: User Permissions

http://help.godaddy.com/article.php?article_id=59

_Keep in mind that with ASP hosting, the root directory of a hosting account will never have write access using an

ASP/ASP.NET script. If you want to specify write access to a subfolder, you must define write access to that folder through

the Directory Management option in your hosting account settings. The Directory Management settings are also used to set up

a "Virtual Root" in IIS by selecting the Set Root option._ Resolve:

** should set user permissions for image/staff and image/services folder.**

Since the hosting is windows hosting, so I can not set permission by FTP tool.

ONLY way:  set READ and WRITE permissions in Godaddy.com control panel:

Directory Management -> click CREATE DIRECTORY button -> input "image/staff", and check on "Write" and "Read" -> click

Continue button -> Click "Edit" button (Don't click "ADD" button since the folder has already created when I use FTP)