How to: Deploy an ASP.NET MVC Application

If your hosting provider already has ASP.NET MVC 1.0 installed on the hosting server, deploying your MVC application is no different that deploying any ASP.NET Web application. However, if the hosting provider does not currently support ASP.NET MVC 1.0, you must upload the required MVC assemblies in the Bin folder of your deployed application.

After ASP.NET MVC is installed, the following assemblies are located in the global assembly cache (GAC) on your computer:

  • System.Web.Mvc (the ASP.NET MVC assembly)

  • System.Web.Routing (a .NET Framework assembly that is required by ASP.NET MVC)

  • System.Web.Abstractions (a .NET Framework assembly that is required by ASP.NET MVC)

If your hosting provider has ASP.NET version 3.5 Server Pack 1 installed, you have to upload only the System.Web.Mvc assembly. If your hosting provider is using ASP.NET version 3.5 or an earlier version, you must deploy all the listed assemblies.

ASP.NET MVC runs in medium trust. Therefore, it should work with the medium-trust policies of most hosting providers. However, check with your hosting provider about trust policies.

We recommend that you use the Publish feature of Visual Studio to publish to a local folder and then upload the files to your hosting provider. You can then test exported files before you copy them to the hosting provider. If the hosting provider supports FTP, you can often skip this intermediate step and publish directly to the hoster's FTP server. For more information, see Walkthrough: Deploying a Web Site Project by Using XCOPY.

Deploying an MVC Application

To deploy an ASP.NET MVC application

  1. In Visual Studio, open the project that you want to deploy.

  2. In Solution Explorer, expand the References node.

  3. Select the following assemblies:

    • System.Web.Mvc

    • System.Web.Routing

    • System.Web.Abstractions

  4. In the Properties window, set Copy Local to True.

  5. In Solution Explorer, right-click the project and click Publish.

    The Publish Web dialog box is displayed.

  6. In Target location (http:, ftp:, or disk path), browse to a local folder and click Open.

  7. Select either Replace matching files with local copies or Delete all existing files prior to publish.

  8. Under Copy, select one of the following, depending on your needs: Only files needed to run this application, All project files, or All files in the source project folder.

  9. If your application contains files in the App_Data folder such as database files, select Include files from the App_Data folder.

  10. Click Publish.

    All the files that are required in order to deploy the application are copied to the target folder.

  11. Test your application by deploying the files to a staging server or virtual machine that does not have MVC installed. If you do not have access to a staging server or a virtual machine, you can uninstall MVC and then test the application locally.

  12. Upload the application to the hosting provider.

See Also

Other Resources

ASP.NET Model View Controller (MVC)