ASP.NET MVC - Publish Website
Learn how to publish an MVC application without using Visual Web Developer.
Publishing Your Application Without Using 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 required DLL files for MVC, Web Pages, Razor, Helpers, and SQL Server Compact (if you use a database).
Sometimes you don't want to use these options. Perhaps your hosting provider only supports FTP? Perhaps your website is based on classic ASP? Perhaps you want to copy the files yourself? Or perhaps you want to use other publishing software like Front Page, Expression Web?
Will you encounter problems? Yes, you will. But you have a way to solve it.
To copy a website, you must know how to reference the correct files, which DLL files need to be copied, and where to store them.
Follow these steps:
1. Use the latest version of ASP.NET
Before you continue, make sure 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 content) from your development computer to the application folder on the remote host (server).
If yourApp_Datafolder contains test data, do not copy this App_Data folder (see point 5 below).
3. Copy the DLL files
Create a bin folder in the application root directory on the remote server. (If you have already 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), then you must copy the SQL Server Compact DLL files:
Copy all files from the following folders:
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#
<configuration>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SqlServerCe.4.0" />
<add invariant="System.Data.SqlServerCe.4.0"
name="Microsoft SQL Server Compact 4.0"
description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=4.0.0.1,Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
</DbProviderFactories>
</system.data>
</configuration>
5. Copy SQL Server Compact data
Do you have an .sdf file containing test data in your App_Data folder?
Do you wish to publish your test data to the remote server?
Most of the time, you wouldn't want to.
If you absolutely must copy the SQL data file (.sdf file), then 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!
Other Extensions