The fun on this issue started when I tried to deploy a basic MVC 3 framework (stock-out-of-the-box) to my ISP server and received the following error:
"Could not load file or assembly
'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot
find the file specified."
My assumption was that this namespace resided under System.Web.WebPages namespace since my project had no reference to a System.Web.WebPages.Razor assembly. In this experience I learned that it is best to start debugging issues at Scott Hanselmins blog; this is the second time in a week that he has helped me through a "bleeding edge" issue that was causing me to hemorrage....
I appreciated that he started this blog with the following quote - it clarified the meaning of "Bin Deploy"
If someone says "just bin Deploy it" they mean "deploy the application with the dependencies copied into the application's /bin folder, rather than running an MSI that installs the dependencies into the Global Assembly Cache (GAC)."
Even though this blog BIN Deploying ASP.NET MVC 3 with Razor to a Windows Server without MVC installed didn't resolve my issue completely (I ran into more issues) the comments within his blog helped fill in the blanks.
In summary - follow his instructions for "The Manual Way to BIN Deploy ASP.NET MVC 3 with Razor" which will have you manually copy the following five files to the bin folder (I manually FTP them to the server's bin since I was debugging/troubleshooting):
-
System.Web.Mvc (I selected this dll from the references list and changed its "Copy local" property setting to True to resolve this requirement)
-
System.Web.Infrastructure.dll
-
System.Web.Helpers.dll
-
System.Web.Razor.dll
-
System.Web.WebPages.dll
-
System.WebPages.Razor.dll
From the Program Files(x86)/Microsoft ASP.NET/ASP.NET Web Pages/v1.0/Assemblies folder, which quickly dispelled my belief that the razor namespace was in System.Web.WebPages; I see now that the dependencies were solved externally.
You'll quickly find that you will require a 7th file
7. System.Web.WebPages.Deployment.dll (from the same folder as the above)
2011.03.27 UPDATE
It is actually easier than noted above!!!
I understand this came with VS 2010 SP1
Right click on your MVC 3 web applicaiton and select "Add Deployable Dependencies"
Select ASP.NET MVC (it will provide everything you need for the RazorViewEngine)
When done you will have the required assemblies in a _bin_deployableAssemblies folder!
Tags:
mvc
Categories:
ASP.NET MVC