Hosting ASP.NET Website

We are going to discuss how to host your ASP.NET website to make it live using a hosting account that you may have purchased. If not, then please get one accordingly with the domain name.

Step 1. Firstly, you have to register for your domain name. After getting your domain name login to your hosting account using your user ID and password.

In your Login panel go to your account tab and then choose MyProducts. On this product page, you will find the following services.

page

Figure 1. My Product Page

On this page click the Manage button straight to the web hosting services. On this page, you have to find out the following options.

Figure 2. Site Options Page

Click the Open Site link placed after File Manager, it takes you to the file location, which is httpdocs directory folder.

In this httpdocs folder, you have to place all your Asp.net *.aspx, *.aspx.cs, *.css, *.js and your Images folder.

Step 2. After uploading all files in your project into that httpdocs folder, you have to create the database for your project. In the above image click Add New Database link and it will take you to the phpMyAdmin page for creating your database.

page

Figure 3. phpMyAdmin page

In the above image click Databases and then click create a new database. Enter your database name, and collation, and hit Go to create a new database.

After pressing Go your database is created and it can be viewed on the left-hand side of your phpMyAdmin page. Then click the database and the following window will appear,

Figure 4. Create Table

In this above image click Create table tab to create your new table for your database. Mention fields and their type and strength set the primary key for your table and then hit the Go button to create a table.

After table creation, you have to link your *.aspx.cs into your database. Here is the connection string coding to connect the database into your aspx page.

Some hosting providers use MySQL for the database, so we need the server IP address and then the port number for MySQL, then only we can connect to the database.

After the database is you can view the IP Address and then the port number of your database is placed after your database. Here is the example image.

IP address

Figure 5. IP address and port number

Now you have to add MySql.Data.dll reference into your project reference folder. Here is my article link for connecting MySQL database in ASP.NET, go through the link and download the dll file here.

After downloading your dll file select your project and click the add reference tab then add this dll to your project.

Now the coding is as follows.

Reference

using System;  
using System.Collections.Generic;  
using System.Web;  
using System.Web.UI;  
using System.Web.UI.WebControls;  
using System.Data;  
using MySql.Data.MySqlClient;

Connection String

MySqlConnection con = new MySqlConnection("Data Source=Server IP Address;port=3306;Initial Catalog=SSFFDB;User ID=ssff;Password=SSFF123!;");

Mysql Command sample

MySqlCommand cmd = new MySqlCommand("INSERT INTO table_name (table_fields) VALUES ()", con);
cmd.ExecuteNonQuery();

Read more articles on how to host a website.


Similar Articles