12

I'm trying desperatly to setup a MVC 4 (in the worst caes 3) with Razor on Monodevelop. I'm sitting on a Mac OS X machine, with Mono 2.11.4.

It seems to not have all the assemblies required. System.Web.Helper for instance, doesn't seem to be found. And MonoDevelop can only find System.Web.Mvc version 3 (With NET framework 4.5 selected) or version 2 (with NET Framework 4.0 selected). Does anyone know how to get MVC 4 with Razor to work?

Robin Heggelund Hansen
  • 4,906
  • 6
  • 37
  • 54

3 Answers3

11

(Razor pages worked with Mono, in theory, with version 2.10.x series, but you had to bundle Microsoft's assemblies with it into your Linux box.)

Since Mono 2.11.1, these assemblies are now bundled by default in Mono, because Microsoft open sourced Razor recently (on March 2012). So: you're using the correct version of Mono.

The catch is that, as explained in this blogpost, MVC4 depends on the async ASP.NET API stack, which is not ready yet in Mono. So yes you can now use Razor with Mono without the need to deploy MS assemblies from Windows, but, you need to stick with MVC3, not 4, for now.

(Copy-pasted my answer from this other stackoverflow question and tweaked it a bit.)

Community
  • 1
  • 1
knocte
  • 16,941
  • 11
  • 79
  • 125
  • Hmm... Doesn't Mono 2.11.4 implement Async/Await? Anyway, starting a MVC 3 project in MonoDevelop does not work either. Even the sample project that is generated when you start a new MVC 3 project compiles completely (or it gets runtime errors) – Robin Heggelund Hansen Sep 23 '12 at 13:45
  • async/await is a C# language feature, and yes, Mono 2.11.4 implements it. I'm talking about the new async APIs of ASP.NET. – knocte Sep 23 '12 at 14:23
  • 1
    What version of MonoDevelop are you using? It is recommended that you use master branch (not yet released) because it contains some work from a GoogleSummerOfCode student that worked on ASP.NET integration. – knocte Sep 23 '12 at 14:24
  • I'll check out the master branch :) – Robin Heggelund Hansen Sep 23 '12 at 15:47
  • With Mono 3.0.6 and latest XamarinStudio, MVC4 is still no dice. Couldn't even get MVC3 to work... MVC need some serious love in Mono. – Robin Heggelund Hansen Mar 28 '13 at 12:03
  • you should be more specific, what error do you see? can you pastebin? – knocte Mar 28 '13 at 15:48
  • @knocte - Have you been through [this](http://stackoverflow.com/questions/30497900/how-to-use-url-action-in-mono) kind of issue? – Zameer Ansari May 28 '15 at 19:28
7

I modified the VS2010 MVC4 Project Template to run out-of-the-zipfile in Xamarin Studio/MonoDevelop on Mac & Linux: http://www.cafe-encounter.net/p1319/run-asp-net-mvc4-on-mono-monodevelop-on-mac-the-c-template-project.

Update: I've done a MVC4 on .Net 4.5 template with notes at http://www.cafe-encounter.net/p1510/asp-net-mvc4-net-framework-version-4-5-c-razor-template-for-mono-on-mac-and-linux including link to github.

Chris F Carroll
  • 11,146
  • 3
  • 53
  • 61
2

According to the Compatibility page on the Mono site MVC4 is supported with the exception of the async features. Unless there is a part of the MVC4 framework that is uses async by default, then those new features will only be a problem if you have added that pattern to your code.

QueueHammer
  • 10,515
  • 12
  • 67
  • 91