Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

ASP.NET Web Pages - Publishing

ASP.NET Web Pages - Publishing a Website


Learn how to publish Web Pages applications without using WebMatrix.


Publish Your Application Without Using WebMatrix

By using the Publish command in WebMatrix (or Visual Studio), you can publish an ASP.NET Web Pages application to a remote server.

This feature copies all your application files, cshtml pages, images, and all the required DLL files for Web Pages, Razor, Helpers, and SQL Server Compact (if a database is used).

Sometimes you don't want to use WebMatrix to publish your application. Perhaps because your hosting provider only supports FTP, perhaps you already have a classic ASP-based website, perhaps you want to copy all the files yourself, or perhaps you want to use other publishing software such as Front Page or Expression Web.

Will you run into problems? Yes, you will. But you have a way to solve it.

To perform a site 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 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).

lamp

If your application contains data,Do Not Copy the Data(see point 4 below).


3. Copy the DLL files

Make sure the bin folder on your remote host contains the same DLL files as on your development computer.

After copying the bin folder, it should contain the following files:

Microsoft.Web.Infrastructure.dll
NuGet.Core.dll
System.Web.Helpers.dll
System.Web.Razor.dll
System.Web.WebPages.Administration.dll
System.Web.WebPages.Deployment.dll
System.Web.WebPages.dll
System.Web.WebPages.Razor.dll
WebMatrix.Data.dll
WebMatrix.WebData


4. Copy Your Data

If your application contains data or a database, such as a SQL Server Compact database (a .sdf file in the App_Data folder), please consider the following:

Do you want to publish your test data to the remote server?

Most of the time, the answer is no.

If you have test data on your development computer, it will overwrite the production data on your remote host.

If you must copy the SQL database (.sdf file), then you should delete all data in the database, then copy an empty .sdf file from your development computer to the server.

That's it. GOOD LUCK!