views:

6075

answers:

6

Does anyone have any information about getting the current versions of ASP.NET MVC (Preview 5) working on Mono 2.0? There was info on the old versions (Preview 2, maybe Preview 3), but I've seen no details about making Preview 5 actually work.

The Mono Project Roadmap indicates ASP.NET 3.5 for Mono 2.4 (next year). Any ideas on how to get this useful before then?

More details: The basic MVC Preview 5 template seems to work, so long as I avoid the root directory. If I request the root, I get:

Server Error in '/' Application
The virtual path '' maps to another application.

Description: HTTP 500. Error processing request.

Stack Trace:

System.Web.HttpException: The virtual path '' maps to another application.
  at System.Web.HttpContext.RewritePath (System.String filePath, System.String pathInfo, System.String queryString, Boolean setClientFilePath) [0x00000] 
  at System.Web.HttpContext.RewritePath (System.String path, Boolean rebaseClientPath) [0x00000] 
  at System.Web.HttpContext.RewritePath (System.String path) [0x00000] 
  at MvcApplication1._Default.Page_Load (System.Object sender, System.EventArgs e) [0x00000] 
  at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] 
  at System.Web.UI.Control.LoadRecursive () [0x00000] 
  at System.Web.UI.Page.ProcessLoad () [0x00000] 
  at System.Web.UI.Page.ProcessPostData () [0x00000] 
  at System.Web.UI.Page.InternalProcessRequest () [0x00000] 
  at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000] 

Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42
+11  A: 

Well a potential is that RewritePath to / has some sort of bug, so just avoid that. Changing the RewritePath(Request.ApplicationPath) to:

HttpContext.Current.RewritePath("/Home/Index");

Seems to fix the problem, and at least the demo works so far.

MichaelGG
+1  A: 

Are you using Mono from svn or stable? What kind of webserver are you using? What kind of Operating system? Do you have rewrite rules in your web server?

I can run preview 4 in Linux with this in the page_load method in default.aspx.cs

HttpContext.Current.RewritePath(Request.ApplicationPath);
 ((IHttpHandler)new MvcHttpHandler()).ProcessRequest(HttpContext.Current);

I need that in windows sometimes too. I didn't test version 5 in Linux yet, so it might not work.

Paco
XSP 2.0, Windows, just using the default MVC Preview 5 template. But after more research, it appears only the RewritePath("/") fails. Everything else we tried seems to work fine.
MichaelGG
That also failed here and that's why I use Request.ApplicationPath instead of "/"
Paco
Except Request.ApplicationPath is coming through as "/".
MichaelGG
+3  A: 

Does anyone care that using ASP.NET MVC on platforms other than Microsoft's (including Mono) is expressly forbidden by the license? To quote:

The Additional Use Rights extend only to the software or permitted derivative works that you create that run on a Microsoft Windows operating system product

"Additonal Use Rights" is defined in a section above as including just about anything beyond reading the code.

IANAL, but it seems to me that such a statement would be put in there precisely to prevent you from running MVC on Mono (at least at this time), especially when you consider that other pre-release components, like F#, don't have this restriction.

Now, maybe you really don't care about the license restriction, but you should at least know about it...

David Mitchell
That seems to only apply to the source license?
MichaelGG
and you can always run mono on top of Windows, can't you?
sumek
Yeah, it looks like MVC, as a beta product, is limited to MS platforms for any type of development use, other than "Reference Use". Well, can't blame them, as selling servers pays for the MVC development!
Jarrod Dixon
It was perfectly fine to run that version on Mono on Windows, if one chose to. Now that the final version is out, this restriction is no longer in place, and you can run it wherever.
jpobst
Looking back on this from 2010: That was the "Microsoft Source License for ASP.NET Pre-Release Components". In April 2009, shortly after releasing version 1.0, Microsoft released ASP.NET MVC under their MS-PL, which has no such clause. It's even an approved open-source license by OSI, and a free software license according to the FSF. So go forth and write ASP.NET MVC code on Mono!
Ken
+1  A: 

Now that Asp.net MVC 1.0 has been released - can anyone tell me if David's point still applies? There seems to be no mention of a restriction to Windows in the user agreement - and indeed the license cited in the link seems to relate to Pre-release software...

Last time I looked, the license restriction was only for development use of the source code anyways.
MichaelGG
It's completely free now! http://weblogs.asp.net/scottgu/archive/2009/04/01/asp-net-mvc-1-0.aspx
Ricardo Nolde
+4  A: 

Asp.Net MVC 1.0 will work with the 2.4 branch of mono but you will still need to fix the RewritePath in page load of default.aspx.cs

A: 

Hi, I am having a trouble. I am trying to run asp.net mvc 1.0 on mono 2.2.I have copied the system.web.mvc.dll to bin directory. I have done HttpContext.Current.RewritePath("/Home/Index");. Still I am having te error:

Server Error in '/' Application The incoming request does not match any route

Description: HTTP 500. Error processing request.

Stack Trace:

System.Web.HttpException: The incoming request does not match any route at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContextBase httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.ProcessRequest (System.Web.HttpContext httpContext) [0x00000] at System.Web.Routing.UrlRoutingHandler.System.Web.IHttpHandler.ProcessRequest (System.Web.HttpContext context) [0x00000] at MvcApplication4._Default.Page_Load (System.Object sender, System.EventArgs e) [0x00000] at System.Web.UI.Control.OnLoad (System.EventArgs e) [0x00000] at System.Web.UI.Control.LoadRecursive () [0x00000] at System.Web.UI.Page.ProcessLoad () [0x00000] at System.Web.UI.Page.ProcessPostData () [0x00000] at System.Web.UI.Page.InternalProcessRequest () [0x00000] at System.Web.UI.Page.ProcessRequest (System.Web.HttpContext context) [0x00000]

Version information: Mono Version: 2.0.50727.1433; ASP.NET Version: 2.0.50727.1433

Markus