ASP.NET MVC - Publishing a Website
Learn how to publish an MVC application without using Visual Web Developer.
Publish Your Application Without Visual Web Developer
You can publish an ASP.NET MVC application to a remote server by using the publish command in WebMatrix, Visual Web Developer, or Visual Studio.
This feature copies all your application files, controllers, models, images, and all necessary DLL files for MVC, Web Pages, Razor, Helpers, and SQL Server Compact (if using a database).
Sometimes you may not want to use these options. Maybe your hosting provider only supports FTP? Maybe your website is based on classic ASP? Maybe you want to copy the files yourself? Or maybe you want to use other publishing software like Front Page, Expression Web, etc.?
Will you encounter problems? Yes, you will. But you have ways to solve them.
To perform the website copy, you must know how to reference the correct files, which DLL files need to be copied, and where to store them.
Please follow these steps:
1.
Use the latest version of ASP.NET
Before you proceed, ensure that your host is running the latest version of ASP.NET (4.0 or 4.5).
2.
Copy the Web folder
Copy your website (all folders and contents) from your development computer to the application folder on the remote host (server).
If your AppData folder contains test data, do not copy this AppData folder (see point 5 below).
3.
Copy DLL files
Create a bin folder in the application root on the remote server. (If you have installed Helpers, the bin folder already exists)
Copy all files from the following folders:
C:Program Files (x86)Microsoft ASP.NETASP.NET Web Pagesv1.0Assemblies
C:Program Files (x86)Microsoft ASP.NETASP.NET MVC 3Assemblies
to the bin folder of your application on the remote server.
4. Copy SQL Server Compact DLL files
If your application uses a SQL Server Compact database (an .sdf file in the App_Data folder), you must copy the SQL Server Compact DLL files:
Copy all files from the following folder:
C:Program Files (x86)Microsoft SQL Server Compact Editionv4.0Private
to the bin folder of your application on the remote server.
Create (or edit) the application's Web.config file:
Example C
5. Copy SQL Server Compact Data
Does your App_Data folder contain .sdf files with test data?
Do you want to publish your test data to the remote server?
Most of the time, you usually do not want to.
If you must copy the SQL data files (.sdf files), you should delete all data from the database and then copy an empty .sdf file from your development computer to the server.
That's it. GOOD LUCK!