My First .NET Website
I would like to share with you my story, for all the other beginners out there. If you are new to web or .NET, hopefully this information will be helpful to you.
The following steps outline from start to finish how to deploy an ASP.NET 2.0 website template to your Lunarpages domain.
View demo: http://starterkits.asp.net/PersonalWebsite/
You must have a Windows hosting plan with SQL Server and be able to log into your Plesk manager. Plesk can be accessed at https://yourdomain.com:8443
, with yourdomain being the name of your domain.
First, make sure your domain is configured for ASP.NET 2.0 and FrontPage support, and that your FrontPage login and password are setup. To find these settings in Plesk, click on your domain name and then the Setup icon.1. Visual Web Developer 2005 Express
(it is free)
This program is a streamlined version of Microsoft Visual Studio and it is free for everybody. It is perfect for creating .NET websites.
Download and install Visual Web Developer 2005 Express. To install, double-click the vwdsetup.exe file that you downloaded and follow the setup wizard. When running the installation, be sure also install SQL Server Express simultaneously.
Download here: http://msdn.microsoft.com/vstudio/express/downloads/2. Personal Web Starter Kit
(it is free)
This is a .NET website template that is already pre-built and ready to deploy right now. It is perfect for publishing your first .NET website with logins, photo gallery and event calendar. There are other starter kits available, such as Club, eCommerce, etc.
Download and install the Personal Web Starter Kit from Microsoft. To install, double-click the pers.vsi file that you downloaded and follow the setup wizard.
Download here: http://msdn.microsoft.com/vstudio/express/vwd/starterkit/default.aspx
These instructions have also been used to successfully install the Classifieds Site Starter Kit.3. Create the Project
Open Visual Web Developer program and click File, then New Website. Under the list of installed templates, you should see the Personal Web Starter Kit that you just installed. Highlight it, then browse to set the location where you would like to store your new website project. Here, you can also choose to use either Visual Basic or Visual C#. Click OK to create the project, then press Ctrl+F5 to launch the website on your local computer.
Using Web Developer, run the site by pressing Ctrl+F5 or the green arrow icon. Now you can begin modifying the site and uploading photos, etc. At minimum, you must run the site at least once
in order to prime the database before exporting it in the next step. You should also go ahead and create an admin account using the ASP.NET Configuration (follow the instructions on the welcome.html page within your project). Basically, click the Security tab, click Create New User and assign the role of Administrator. When you are done, we will export/import the SQL database and upload the site to Lunarpages.4. SQL Server Hosting Toolkit
(it is free)
This is a handy tool to copy your database from your computer to Lunarpages. It creates a script file that will convert the SQL Express database to SQL 2000 format for use on Lunarpages.
Download and install the SQL Server Hosting Toolkit from CodePlex (and is backed by Microsoft). To install, double-click the DatabasePublishingWizard.msi file that you downloaded and follow the setup wizard.
Download here: http://www.codeplex.com/sqlhost/Wiki/View.aspx?title=Database%20Publishing%20Wizard
You cannot export your local database to Lunarpages directly. However, you can export it to a .sql file and then import it to your Lunarpages database. First, locate the database in Visual Web Developer, Database Explorer. This particular Personal Website project includes two databases. To use the SQL Server Hosting Toolkit within Visual Web Developer, right-click on the ASPNETDB.MDF database and choose ‘Publish to Provider,’ then follow the wizard. Repeat the process for the Personal.mdf database. Now you have two new .sql files.
Additional instructions here: http://weblogs.asp.net/scottgu/archive/2006/12/22/recipe-deploying-a-sql-database-to-a-remote-hosting-environment-part-1.aspx 5. My Little Admin Tool
In this example, we will import both .sql files into a single MSSQL database on Lunarpages to make things easier. This way, once you publish your Personal Website, it will use the new database you created on Lunarpages.
Within Plesk, click on your domain name, then the Databases icon. Click the ‘Add New Database’ icon and follow the wizard for adding a new MSSQL database. Next, click the ‘Add New DatabaseUser’ icon and follow the wizard. Now you have an empty MSSQL database named myDatabase with username and login as myUsername and myPassword.
Now you are ready to import the .sql files to your new myDatabase, which will recreate your Personal Website database structure and contents exactly how it was from Visual Web Developer on your local computer.
Within Plesk, click on your domain name, then the My Little Admin Tool icon. Or, go directly to: http://lesuth.lunarpages.com/mylittleadmin
Login with your new database username and password, myUsername and myPassword. Also, be sure to click ‘Options’ and select ‘TCP/IP’ network protocol connection
in order to log in.
Within My Little Admin Tool, click Tools and then New Query. Open the .sql file in Notepad and copy and paste the text into the New Query box. Be sure to select myDatabase from the dropdown box. Click Submit and your script should run successfully. Repeat this process for both .sql files. Now your myDatabase is fully populated.6. Connection String
Before you upload your website, you need to change your connection string in the web.config file to point to your new myDatabase on Lunarpages. Note, you need to change it back in order to run the site locally again later.
Lunarpages hosts SQL databases on different servers than where websites are hosted. Your SQL database may be located on either Castor at 18.104.22.168 or Raptor at 22.214.171.124 (newest).
Within Visual Web Developer, open your Personal Website project and modify the web.config file accordingly.
Local connection string:
<add name="Personal" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|Personal.mdf" providerName="System.Data.SqlClient" />
<add name="LocalSqlServer" connectionString="Data Source=.\SQLExpress;Integrated Security=True;User Instance=True;AttachDBFilename=|DataDirectory|aspnetdb.mdf" />
Lunarpages connection string:
<add name="Personal" connectionString="Server=126.96.36.199;Database=myDatabase;User ID=myUsername;Password=myPassword;" />
<add name="LocalSqlServer" connectionString="Server=188.8.131.52;Database=myDatabase;User ID=myUsername;Password=myPassword;" />
I cannot tell you why you need both the Personal and the Local connection strings, as I am still new to .NET. What I do know is that we combined the original two databases into one new database. Therefore, we need to point the two separate database connection strings to the same newly created database.
Note: It appears that there is only one connection string defined in the Classifieds starter kit. Still, you must be sure to add both the Classifieds and the Local connection strings just like shown above.7. Upload Website Files
You are almost finished. Now it is time to publish your site by uploading all the site files.
Within the Visual Web Developer menu, click Website then Copy Website. Click the Connect button and enter your domain name and login info. Once you connect, the remote files (on your Lunarpages domain) are displayed on the right panel, and your local files (on your computer) are displayed on the left panel. Like other FTP programs, files can be transfered to and from by using the directional arrow buttons in between the two panels.
In this example, we will create a new folder called myPersonalWeb on the remote site. Next, highlight all the files on the left panel and click the right arrow to upload the entire project to the myPersonalWeb folder on the remote site.
After the site is published, open your browser to view your brand new website. The address may look something like this: http://www.mydomainname.com/myPersonalWeb
At this point it is likely that your website will display an error page. The next step will help you diagnose and solve one common error.8. Create Virtual Directory
After you have uploaded your site and imported your database, your site may error the first time you try to view it on the internet. Below is a common error and solution.
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
If you receive an error similar to this, you should create a virtual directory and configure it as an application in Plesk.
Within Plesk, click on your domain name, then the Web Directories icon. Click the ‘Add New Virtual Directory’ icon. In this example, we will name the new virtual directory the same as the folder that your website was published to, myPersonalWeb, and we will point to httpdocs/myPersonalWeb. Click OK, and then agree to the message that your physical folder will be converted into a virtual directory.9. Test Website
Open your browser and view your website. The address may look something like this: http://www.mydomainname.com/myPersonalWeb
. Now your website should display properly. It should look exactly like it did from Visual Web Developer on your local computer.
This concludes the how-to steps for creating your first .NET website.
If you need to later modify or update your website or database from Visual Web Developer on your local computer, you may do so. Then, all you need to do is publish your site files again and also create new .sql files and import them into your Lunarpages database.
I hope this information was helpful.