views:

182

answers:

2

I am having trouble getting routing to work on mono. The default route works fine but nothing else does.

These are the routes I have setup:

        routes.MapRoute(
            "HelloRoute",
            "Hello/{name}",
            new { controller = "Home", action = "Hello" }
        );

        routes.MapRoute(
            "Default",
            "{controller}/{action}/{id}",
            new { controller = "Home", action = "Index", id = "" }
        );

and on my HomeController I have the corresponding action:

 public ActionResult Index ()
 {
  ViewData["Message"] = "Welcome to ASP.NET MVC on Mono!";
  return View ();
 }

        public ActionResult Hello(string name)
 {
  ViewData["Message"] = "hello "+name;
  return View ();
 }

now if I navigate to http://localhost/ I get the message Welcome to... but if I go to http://localhost/Hello/World I get an error:

value name controller does not match any of the values.

Description: HTTP 500. Error processing request.

Stack Trace:

System.InvalidOperationException: value name controller does not match any of the values. at System.Web.Routing.RouteData.GetRequiredString (System.String valueName) [0x00000] at System.Web.Mvc.MvcHandler.ProcessRequest (System.Web.HttpContextBase httpContext) [0x00000] at System.Web.Mvc.MvcHandler.ProcessRequest (System.Web.HttpContext httpContext) [0x00000] at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest (System.Web.HttpContext httpContext) [0x00000] at System.Web.HttpApplication+c__Iterator2.MoveNext () [0x00000] at System.Web.HttpApplication.Tick () [0x00000]

am I doing something obviously wrong?

Apart from the aditional route, action and view this is a standard asp.net mvc project created in Monodevelop.

A: 

It seems like a bug in the ASP.NET MVC templates for MonoDevelop as suggested in the comments section of this post.

Darin Dimitrov
Just created an mvc app in visual studio and tried that.As expected all the default routes worked, but again my custom ones did not.So I am guessing it is not so much a problem with the mvc templates on mono but the actual routing.
Derek Ekins
You must be missing something because I did exactly the same thing in Visual Studio 2008 and both routes worked fine as expected.
Darin Dimitrov
Sorry it worked when I ran it on windows. After moving it to mono+apache it didn't work.
Derek Ekins
A: 

Turns out that this was a bug in the mono routing implementation.

I filled a bug report here: https://bugzilla.novell.com/show_bug.cgi?id=500739. And it has now been fixed, although I haven't tried it yet.

Derek Ekins