Update This was written for difficulties with deploying an MVC 2 app. I have written a new blog post about deploying an ASP.NET MVC 3 web application to keep you up to date with the new technologies.
When I installed Visual Studio 2010 on my local machine it came with all the fruit included (.NET4 framework, MVC2 etc) so the System.Web.Mvc.dll can be found in my machine's GAC (C:\Windows\assembly). However, since there is no need to bloat the web servers only the plain old .NET4 framework has been installed on the test servers. This does NOT include the MVC assembly and that is why it cannot be found by the web application.
You need this assembly to be on your web servers that you are deploying to but you want to avoid having to copy them into the GAC manually and doing all that
gacutil mess or maybe you don't have access to your servers if they are hosted by godaddy or something.Solution
You need to make theSystem.Web.Mvc assembly bin deployable... okay that doesn't sound easy but here is how to do it for the necessary MVC references:Simply right click the reference and select 'Properties':
Then change 'Copy Local' to 'True':
Note
If your server has .NET 3.5 sp1 installed the new(ish) assemblies System.Web.Routing and System.Web.Abstractions will already be in the GAC. If you had previously deployed an MVC 1 application to a .NET 3.5 server you may remember having to deploy the other two assemblies too. Since MVC2 requires at least .NET 3.5 sp1 you will not need to worry about these assemblies, justSystem.Web.Mvc.




Thanx, just what I needed!
ReplyDeleteCool!
ReplyDeleteThanks for the explanation. I was really struggling to get my MVC 2 app deployed to IIS 6 and didn't know if the server wasn't properly configured or if it was a deployment issue.
ReplyDeleteThanks! Deployed .net 3.5 project to GoDaddy; had to change that setting only for System.Web.Mvc.
ReplyDeleteWorks great, thx
ReplyDeletethanks for your valuable tip and was able to launch my mvc app however the images and js queries doestn seem to b working.
ReplyDeletei read in http://haacked.com/archive/2008/11/26/asp.net-mvc-on-iis-6-walkthrough.aspx that
HttpContext.Current.RewritePath(Request.ApplicationPath); has to b changed to
HttpContext.Current.RewritePath(Request.ApplicationPath, false);
m not sure where do i change this..pls help
Looks like he's talking about the default.aspx.cs in the IIS root. It was put their by IIS itself
ReplyDeleteTried to deploy my first ASP.NET MVC website to my VPS, got the error 'Could not load file or assembly 'System.Web.Mvc'. Oh, i thought okay lets install .NET 4.0 Standalone my server, spent my life doing that releasing then that it didnt bloody solve the problem... at which point im seriously pi**ed off
ReplyDeleteSo i turned to goggle for 'Could not load file or assembly 'System.Web.Mvc', came to britishdeveloper.co.uk (2nd in goggle by the way, before forums.asp.net), make System.Web.MVC bin deployable boom, problem solved.
Im more annoyed that .NET 4.0 gave me the impression that it'd have MVC 2 innit.
Thank you very much!! You saved my day.
ReplyDeleteThanks :)
ReplyDeleteVery useful.
ReplyDeleteThanks
Thanks from Barcelona.
ReplyDeleteVery useful :)
you kill my nightmares
ReplyDeletethank you from sheffield
Here is a full tutorial explaining how to configure server and publish MVC2 application
ReplyDeletehttp://arturito.net/2011/01/21/publishing-asp-net-mvc2-application-on-windows-server-2008-iis-7-with-visual-studio-2008-on-platform-net-3-5-sp1/
Thanks!!!
ReplyDelete