How to deploy asp.net, C# website on an online server


How to deploy asp net, C# website on an online server

Working with asp.net website on localhost is easy, but there are huge difficulties while uploading or deploying the website on the server. The following steps should be kept in mind while uploading the website on the server (asp.net).

The .mdf database file you created on localhost will not work on the server, that .mdf file has unlimited database and no restriction for creating tables and while online server has restrictions in creating tables (for shared hosting), so these .mdf file will not work, even tough you have given proper connection string in web.config

Step 1 : Copy all .aspx and .aspx.cs files on the server.

Make sure that you copy all the exact files from your directory to the server directory. To get all the files, right click on solution explorer and click on ‘open files in File explorer’. There you will have all the files (aspx and aspx.cs seperate), you can copy the files to the server either using inbuilt functionality of the server on the website or using FileZilla.

How to deploy asp net, C# website on an online serverUsing filezilla to transfer the files to the server.

Filezilla is one of the best softwares to transfer your files from your folder directory to server directory, to transfer files to the server you will need the following parameters.

  • One FTP account
  • The ip address your website (will be given in control panel or contact your hosting manager for details)
  • Username of FTP account
  • Password of FTP account

How to deploy asp net, C# website on an online server

After filling these details click on quick connect then it will authenticate with the server once the connection is established then you will get a list of files, then there would be a file named ‘httpdocs’ it should be there if it isn’t there then create a folder named httpdocs or contact your hosting manager and ask him to create a folder named httpdocs. This is the most important folder it contains all the essential linking of the website, its the base folder, all modifications to the website should be done from httpdocs folder.

Step 2: Create a database on the server.

If you are using asp.net service then most probably you would be using Parallels Plesk. This is an important step for creating database, as mentioned earlier that .mdf files will not work on the server while it would be working on localhost. You must manually create a database on the server and link that database using your web.config file.

Step 2.1 : Click on database in your parallels control panel.

How to deploy asp net, C# website on an online server

Step 2.2 : Click on add new database.

How to deploy asp net, C# website on an online server

Step 2.3 : Fill appropriate details about the database.

Make sure to select Microsoft SQL Server and not MySQL.

How to deploy asp net, C# website on an online server

Step 2.4 : Click on webadmin.

Go to webadmin. You can also clone the database for testing purposes.

How to deploy asp net, C# website on an online server

Step 2.4 : Click on Tools -> Query Analyzer.

How to deploy asp net, C# website on an online server

Step 3 : Create a script of your complete database.

  1. In Server Explorer, select one or more tables and choose Export Data on the shortcut menu.

    The Browse for Folder dialog box appears.

  2. In the Browse for Folder dialog box, select a target folder in your database project (such as Create Scripts) and click OK.

    This adds the necessary .dat files to your database project.

Step 4 : Copy and paste the contents of .sql file created in query analyser.

Copy and paste the sql file created. Note : If you are getting an error in query analyser then you must individually create scripts of tables and paste the scripts in the query analyser this will definately work.

Step 5 : Get the connection string of newly created database on the server.

Click on  ‘myLittleAdmin Lite‘ (on top of the tree on left div), there complete details about connection string will be given, copy the details and replace the details of the connection string in your web.config file.

Thats all for deploying a website on asp.net server, stuck at some point, just leave a comment below and will try to revert back asap.

These are step by step on how to deploy a website on server using godaddy, although your server company might be different, but the steps are almost the same

      • It is redirecting to 404 page not found.
        Even i tried to insert data into a table using commands through a button and i think that it should atleast insert the data into the table but the error is same 404 not found.

        I have used sql commands on a button click to insert the data . Is there any problem with code having sql commands which are executing on the button click.

        • is it the 404 error or an exception ?
          initially deploying a website, the ‘trust level’ must be set to ‘full’
          make changes in web.config file

          < * system.web>
          < * trust level="Full" originUrl="" />
          < * /system.web>
          (remove *)
          or is the connection made properly with the database ?

          • 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.Data.SqlClient.SqlException: Login failed for user ‘——‘.
            this is the exception i have been getting on all the pages.

  1. @Akash Sharma thats because the password you are entering in web.config and password you are entering while accessing the mylittleadmin are different, make sure that you point to correct server (184.*) and the password is entered correct.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

CommentLuv badge