ASP.NET MVC - Publishing a website
Learn in this section How ASP.NETMVC websites are published.Learn how to publish MVC applications without using Visual Web Developer.
Publish 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 necessary DLL files for MVC, Web Pages, Razor, Helpers, SQL Server Compact (if using a database).
Sometimes you don't want to use these options. Maybe your hosting provider only supports FTP? Maybe your website is based on classic ASP? Perhaps you would like to copy these files yourself? Or maybe you want to use some other publishing software such as Front Page, Expression Web, etc.?
Will you encounter problems? Yes, it will. But you have a way around it.
To perform a 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, 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 machine to the application folder on the remote host (server).
If your App_Data folder contains test data, please do not copy the App_Data folder (see point 5 below for details).
3. Copy the DLL file
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 in 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 application's bin folder on your remote server.
4. Copy the SQL Server Compact DLL file
If your application uses a SQL Server Compact database (a .sdf file in the App_Data folder), then you must copy the SQL Server Compact DLL file:
Copy all files in the following folders:
C:Program Files (x86)Microsoft SQL Server Compact Editionv4.0Private
to the application's bin folder on your remote server.
Create (or edit) the application's Web.config file:
ExampleC#
<?xml version="1.0" encoding="UTF-8"?><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 a .sdf file with test data in your App_Data folder?
Do you want to publish your test data to a remote server?
Most of the time it's generally not expected.
If you must copy the SQL data files (.sdf files), you should delete all data in the database and copy an empty .sdf file from your development computer to the server.
That's it. GOOD LUCK!
That's all there is to publishing an MVC application without using Visual Web Developer.