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.
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
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.
Step 2.2 : Click on add new database.
Step 2.3 : Fill appropriate details about the database.
Make sure to select Microsoft SQL Server and not MySQL.
Step 2.4 : Click on webadmin.
Go to webadmin. You can also clone the database for testing purposes.
Step 2.4 : Click on Tools -> Query Analyzer.
Step 3 : Create a script of your complete database.
- In Server Explorer, select one or more tables and choose Export Data on the shortcut menu.
The Browse for Folder dialog box appears.
- 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.