Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

ASP.NET MVC - Published


May 12, 2021 ASP.NET


Table of contents


ASP.NET MVC - Publishing Site

This section learns ASP.NET MVC website is published.

Learn how to publish an MVC application without using Visual Web Developer.


Publish your application without using Visual Web Developer

By using publishing commands in WebMatrix, Visual Web Developer, or Visual Studio, you can publish a ASP.NET MVC application to a remote server.

This feature copies all your application files, controllers, models, images, and all required DLL files for MVC, Web Pages, Razor, Helpers, SQL Server Compact (if you use a database).

Sometimes you don't want to use these options. M aybe your host provider only supports FTP? M aybe your site is based on a classic ASP? M aybe you'd like to copy these files yourself? Or maybe you want to use other publishing software such as Front Page, Expression Web, etc.?

Are you going to have a problem? Y es, it will. But you have a way to fix it.

To perform site replication, 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 proceed, make sure that your host is running the latest version of the 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 your App_Data folder contains test data, do not copy App_Data folder (see point 5 below).


3. Copy the DLL file

Create a bin folder in the root of the application on the remote server. (If you already have Helpers installed, 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

the bin folder of the application to your remote server.


4. Copy the SQL Server Compact DLL file

If your application uses the SQL Server Compact database ( a .sdf file in the App_Data folder), 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

the bin folder of the application to your remote server.

Create (or edit) a web.config file for your 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"
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 App_Data files containing test data in your .sdf folder?

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

Most of the time it's generally not desirable.

If you must copy 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ļ¼

This is where you publish the entire contents of your MVC application without using Visual Web Developer.