I am trying to launch MVC5 website on my Linux box using Mono and XSP4. It works with no views however when I try to render something it gives me errors.
Here is my test code. Note that I didn't change anything, this is basically a blank site without EF or any other libraries. Just bare-bone MVC5 + Razor.
public ActionResult Index()
{
// return Content("'sall good"); // works
return View();
}
System.InvalidOperationException
Could not locate Razor Host Factory type: System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): System.Web.WebPages.Razor.
Stacktrace
at System.Web.WebPages.Razor.WebRazorHostFactory.CreateFactory (System.String typeName) [0x00000] in <filename unknown>:0
at System.Collections.Concurrent.ConcurrentDictionary`2+<GetOrAdd>c__AnonStorey3[System.String,System.Func`1[System.Web.WebPages.Razor.WebRazorHostFactory]].<>m__0 () [0x00000] in <filename unknown>:0
at (wrapper delegate-invoke) System.Func`1<System.Collections.Generic.KeyValuePair`2<string, System.Func`1<System.Web.WebPages.Razor.WebRazorHostFactory>>>:invoke_TResult__this__ ()
...
I've tried to change Version=5.0.0.0 to 4.0.0.0 and 3.0.0.0 etc but nothing works. I still get the same error just now it's about 4.0.0.0.
Is there any hope?
The problem is in Web.config
that is inside /Views
folder. system.web.webPages.razor
host
parameter must match exactly with MVC version.
For example if you have MVC 5.2.2.0 then it should look like <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
.