Deploy ASP.NET MVC

Sometimes when we want to deploy ASP.NET MVC 3 web application to our hosting provider, some assemblies are not to be installed in the Global Assembly Cache (GAC) on the server, and then what is the hack to deploy web application without any issue. We just need to include the needed set of assemblies to run asp.net mvc 3 web application properly in the bin folder.

In the previous version you need to install the following assemblies if you did not install .NET 3.5 SP1.

  • System.Web.Mvc.dll
  • System.Web.Abstractions.dll
  • System.Web.Routing.dll

But if your purchased hosting server does not have support of the ASP.NET MVC 3, you are required to deploy the following set of assemblies in the bin folder of your deployed web application on the hosting server.

  • Microsoft.Web.Infrastructure.dll
  • System.Web.Helpers.dll
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll

You can figure out that not every assembly is referenced. It is not required to reference all of the following assemblies when deploying ASP.NET MVC 3 web application. If they are not available in the GAC you need to be placing the required assemblies in the bin folder.

 

Referenced Assemblies

Referenced Assemblies

 

Visual Studio team provides you a way to add only deployable assemblies to right click on the project and select the Add Deployable Assemblies. You can show the dialog in the following example.

 

Add Deployable Dependencies

Add Deployable Dependencies

 

When we build as ASP.NET MVC application, we only need to check the first ASP.NET MVC option to assemble the required assemblies in the _bin_deployableAssemblies. In the case of using Razor View Pages we need to check the second option.

When we click “OK” then what would happen?

 

Deployable Assemlies

Deployable Assemlies

 

New folder named _bin_deployableAssemblies is created and the required assemblies are copied into this folder. Web projects have a built in build task that copies any assemblies in this folder into the bin folder when the project is compiled.

Note that this dialog did not add any assembly references to these assemblies. That ensures that the types in these assemblies do not pollute Intellisense, while still being available to your deployed application. If you actually need to use a type in one of these assemblies, you are free to reference them.

So here is the kicker. If you are building a web application, and you need an assembly deployed but do not want it referenced and do not want it checked into the bin directory, you can simply add this folder yourself and put your own assemblies in here.

If you have ever run into a problem where an ASP.NET MVC site you developed locally does not work when you deploy it, this dialog may be just the ticket to fix it.

Resources:
http://haacked.com/archive/2011/05/25/bin-deploying-asp-net-mvc-3.aspx

ASP.NET MVC

1 comment


  1. Paul

    Thanks. this is exactly what I needed.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>