Running MVC 3 in Medium Trust

My latest and greatest love has to be MVC3, its a great web technology and razor has to be the cleanest templating language i have used by far, its simple, powerful and produces beautiful unaltered html, as fresh as it would be if i'd written it in notepad. However MVC3 is new (relatively speaking ..) and as such hosting companies can be slow/reluctant on the installation of it. If like me you aren't afforded the luxury of a standalone server, ec2 instance etc for every little side project this can be a problem. The only real alterative for dotnet hosting is "shared hosting" through a hosting company. Many of these already have mvc2 installed as its been about and "proven" for some time BUT screw that; i want razor in all its supreme glory. Do not despair! help is at hand getting mvc3 running on a host already running mvc2 is actually pretty easy! huzzah! all we have to do is deploy the dll's mvc3 needs into our applications bin folder and like magic you'll have mvc3 running on shared hosting and as an extra special bonus it even runs under medium trust which is what most shared hosting companies rightfully supply. Which dlls do i need? i hear you cry. Luckily for you i'm on hand with this handy guide. First of all open explorer and navigate to C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies (this could also be C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies (paths are right for windows7; you should be able to find the information on the internets for other os's)

From this folder simply copy the following files

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

if your planning on using deployment you'll also need System.Web.WebPages.Deployment.dll. Now paste these files to a folder you can get at the easy. In addition to these files you'll also need the mvc3 dll, this can be found in C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies and is called System.Web.Mvc.dll, copy this file and paste it into the directory where you stored the other files, you should be left with something like this

 (ignore the fact this is a mac finder window, i run win7 on my mac in parallels for windows development)

We now have all the dll's needed to run mv3 in medium trust on shared hosting; simply copy them to your applications bin folder on your shared hosting and voila! mvc3 with razor on shared hosting, medium trust. Hopefully this is going to be the first of a series of posts about getting popular dotnet libraries working under medium trust! providing i can get the ones i want to blog about working .. :P


comments powered by Disqus