After the release of ASP.Net MVC RC 2, we are now waiting for the RTM release but some of us wanna use RC 2 already... But how to deploy it on a shared hosting acount is the mind-exploding problem...
@ 12-18-2010
by Tugberk Ugurlu


UPDATE on 2011, 02.26

I have wrote another blog post on ASP.NET MVC Deployment problems you might have related to your server. If you are still having problems (especially, if you are getting 404 exceptions for extensionless URLs), you might want to have a look at on "Running ASP.NET MVC Under IIS 6.0 and IIS 7.0 Classic Mode : Solution to Routing Problem"

asp-net-mvc-3.gifOn the 10th of December in 2010, Microsoft ASP.Net MVC team has released the MVC 3 RC 2 and it has some good stuff inside which RC 1 didn't have. It is not so much different but there are some breaking changes, especially ViewBag thing.

You could find more information about ASP.Net MVC RC 3 goodies on ScootGu's blog post or Phil Haacked blog post.

The MVC 3 RC 2 has come from go-live-license so you can use this in production if you wish. But the main problem rises here if you are in a shared hosting environment. As you know, shared hosting providers are not willing to install the new releases unless it is for sure that there is no detected bug in the package.

I thought that would be a big problem for me [because I am still in shared hosting environment :)] but deploying the necessary assemblies as manually is the solution. Scott Hanselman has a great post on how to deploy an MVC 3 application into a shared hosting environment. The article covers all the necessary steps. One problem is that if you do exactly as it is there, you will sure have a problem if you are deploying the RC 2 of the MVC 3.

The yellow screen of death will give you the following error;

Could not load file or assembly 'System.Web.WebPages.Deployment, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

The error will be thrown by the system because it needs System.Web.WebPages.Deployment.dll as well. The solution of this little problem is simple;

Navigate to C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies (this could be C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies on Windows 7) inside the windows explorer and you will see some files inside the folder;

asp.net-mvc-3-rc-2-bin-deployment-shared-hosting-environment-full.PNG

You need those 6 dll files. In addition to that you will also need System.Web.Mvc.dll (version 3.0.11209.0). You will be able to find that dll file by navigating to C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies (that should be C:\Program Files (86x)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies in Windows 7 [I'm not sure though])

asp.net-mvc-3-rc-2-bin-deployment-shared-hosting-environment-mvc-folder.PNG

Finally you should all have the following dlls in hand;

  • Microsoft.Web.Infrastructure
  • System.Web.Razor
  • System.Web.WebPages
  • System.Web.WebPages.Razor
  • System.Web.Helpers
  • System.Web.WebPages.Deployment (If you are deploying MVC RC 2, this assembly is necessary to deploy)
  • System.Web.Mvc

I made a copy of those dlls and put them together inside a folder so that I could reach them easily whenever I need them;

essential-MVC-3-0-RC-2-with-razor-dlls.PNG

We have all the necessary files in our hands and so what now !

There are some conventions here that you could choose. The way I follow is that;

  • I used built in Visual Studio Publish tool to publish my application to the production side.
  • After publishing was complated, I simply copied those 7 dll files into the bin folder inside the root directory of my application.

visual-studio-2010-publish-tool-goodies.png
Visual Studio 2010 Publish Tool

That was it ! [Of cource I didn't put the System.Web.WebPages.Dployment.dll into the production side and I got the error firstly :)]

Finally, my bin folder has the necessary assembly files to run the application;

magic-bin-folder-of-asp-net-mvc-3-rc-2-application.png




Hi 🙋🏻‍♂️ I'm Tugberk Ugurlu.
Coder 👨🏻‍💻, Speaker 🗣, Author 📚, Microsoft MVP 🕸, Blogger 💻, Software Engineering at Deliveroo 🍕🍜🌯, F1 fan 🏎🚀, Loves travelling 🛫🛬
Lives in Cambridge, UK 🏡