Mono and ASP.NET MVC v3

by grendel 17. January 2011 09:23
Microsoft has recently released the next version of the ASP.NET MVC stack and many of you have been asking whether Mono supports it. The answer is complicated since this MVC release is much bigger and includes more components than the previous ones. Unfortunately not all of those components have been released as open source software (although they come with the right to redistribute the assemblies) and therefore MVC integration with the Mono sources and build system makes no point at the moment. The highlight of the release is the new Razor template engine which is among the source-less components, so the Mono build of MVC would have to be done without support for Razor, which would probably take away all the fun from using it for many people. Having said that, I have managed to get to compile with current Mono from master after stubbing out several assemblies (read below for the list) and disabling Razor. The code lives in my local git branch and is not going to hit the Mono repository just yet. The reason for this is that we have decided to first make sure that MVC binaries from Microsoft work fine with Mono and only then set out to implement the non-open source assemblies it relies upon. I committed several changes (commits: c372ab7, 0582257, 1d5e3d4, d18d086, aa2ad86, cd511ea and 3e62637) which made it possible to run an MVC v3 application generated from the default VisualStudio template using several assemblies distributed by Microsoft. To get the application working you need to put in your bin/ folder the following dlls:
  • System.Web.Mvc.dll
  • System.Web.Razor.dll
  • System.Web.WebPages.Deployment.dll
  • System.Web.WebPages.dll
  • System.Web.WebPages.Razor.dll
All of the above assemblies, with the exception of the Mvc one, come without sources and will be at some point implemented in Mono. Also note that the Microsoft.Web.Infrastructure assembly added with the above commits is mostly a collection of stubs so you might (and will) come across the NotImplementedException from time to time. So, with the above changes you should be able to give MVC v3 on Mono a spin - if you come across any issues with running your app on Mono, do file a bug report attaching your application (or, if it is too big/private/secret/etc, a small test case which triggers the issue) to help us iron out all the rough edges.

Update: Gonzalo got Razor working under Mono - please report all the issues you have with your Razor applications under Mono! Congrats, Gonzalo :)

Tags: ,

Mono | ASP.NET | MVC | MVC3

Comments (12) -

Johan Tavelin
Johan Tavelin
1/17/2011 2:27:27 PM #

Isn't it the source code for those assemblies what can be found under /mvc3-rtm-sources/webpages/src in the MVC 3 RTM source code zip file on codeplex? (http://aspnet.codeplex.com/releases/view/58781).

It looks to me like they are open source.

Reply

grendel
grendel
1/17/2011 4:09:37 PM #

They are not open source. They are released under the MSL (Microsoft Source License) which contains platform limitation clause. Unless they are re-licensed under MsPL I cannot (and don't want to) even look at them. Furthermore, unless one chooses to exercise the Additional Rights outlined in the license, the code may serve only as reference material (that alone, despite other factors, prevents the code from being included in Mono and its build system)

Reply

Fujiy
Fujiy
1/17/2011 9:27:05 PM #

And the compiled assembly? You can put at mono?

Reply

grendel
grendel
1/18/2011 2:25:44 AM #

You can redistribute the assemblies with your application, yes (but we can't put them in Mono)

Reply

Fujiy
Fujiy
1/17/2011 2:55:56 PM #

Razor is open source, but not Ms-Pl (yet)

Reply

Oleg Tarasov
Oleg Tarasov
1/20/2011 8:35:35 AM #

Hi! I've just compiled a fresh version of Mono from git repository and tried to deploy a simple MVC3 app (just a standard Razor app template). It gives me HTTP 500 with the following message:

"System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies."

I've checked the GAC and Microsoft.Web.Infrastructure.dll is present there. I also copied all the required dlls into my app's bin folder. What can be a problem here?

Reply

grendel
grendel
1/20/2011 8:47:07 AM #

Make sure you compiled+installed the right version of Mono, that you're using the right parallel environment etc. It's best if you take the current Mono from master and do a full bootstrap.

Reply

adrin
adrin
1/20/2011 9:14:31 AM #

http://razorengine.codeplex.com/license says Microsoft Public License (Ms-PL)

Marek would you be so kind to post a working ASP.NET MVC 3 project source somewhere? Just for reference as I cant seem to get the default vs2010 project to run using latest master mono version.

Reply

grendel
grendel
1/20/2011 4:58:49 PM #

The razor engine you link to is a different beast - not the Microsoft .NET one.

As for MVC 3 project - I compile it with VS2010 for testing and it works just fine on Mono/master/mono-2-10.

Reply

Anton Heryanto
Anton Heryanto
2/10/2011 1:12:50 AM #

i got problem when using mono master 2_10 to run ASP.NET MVC3 With View ASPX and Razor. Every HttpPost Request return empty content or null. Any Idea what cause of this problem.

Reply

grendel
grendel
2/10/2011 9:05:31 AM #

So which is it - master or 2.10? And if the latter, is it RC or is it from git?

Reply

Anton Heryanto
Anton Heryanto
2/18/2011 10:28:35 AM #

i pull mono 2.10 from git.. and just find out that the Bug 668655 which listed this problem already fix by u. thank u very much for quick response. mono is the reason i learn c#...

Reply

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

RecentComments

Comment RSS