ASP.NET MVC - Publish a website
- Previous Page MVC HTML Helper
- Next Page MVC Reference Manual
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 will copy all application files, controllers, models, images, and all necessary DLL files that may be used for MVC, Web Pages, Razor, Helpers, SQL Server Compact (if a database is used).
Sometimes you may not want to use this option. Maybe your host provider only supports FTP? Maybe your website is based on classic ASP? Maybe you want to copy files yourself? Maybe you are using other publishing software?
Will you encounter any problems? Yes, you will. But we can solve it.
To perform website copying, you must understand how to reference the correct files, which DLL files to copy, and where to store them.
Please follow these steps:
1. Use the latest version of ASP.NET
Before you continue, make sure that your host is running the latest version of ASP.NET (4.0).
2. Copy Web folder
Copy your website (all folders and content) from the development machine to the application folder on the remote host (server).
If App_Data The folder contains test data, please do not copy this App_Data folder.
3. Copy DLL files
Create a bin folder in the application root directory on the remote server. (The bin folder already exists if you have installed the helper)
Copy all the following files from your folder:
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies
to the bin folder on the remote server.
4. Copy SQL Server Compact DLL file
If your application uses the SQL Server Compact database (.sdf file in the App_Data folder), you must copy the SQL Server Compact DLL file:
Copy all the following files from your folder:
C:\Program Files (x86)\Microsoft SQL Server Compact Edition\v4.0\Private
to the bin folder on the remote server.
Create or edit the Web.config file in the application:
Instance C#
<?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" 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
Does your App_Data folder contain a .sdf file with test data?
Do you want to publish test data to a remote server?
Most of the time, it is not desired.
If you have to copy an SQL data file (sdf file), you should delete all the data in the database and then copy this empty .sdf file from the development machine to the server.
That's it. Good luck to you!
- Previous Page MVC HTML Helper
- Next Page MVC Reference Manual