This is Xamarin's bug tracking system. For product support, please use the support links listed in your Xamarin Account.
Bug 9116 - System.Web.Routing doesn't properly utilise value-type default parameters
: System.Web.Routing doesn't properly utilise value-type default parameters
Status: RESOLVED FIXED
Product: Class Libraries
Classification: Mono
Component: Sys.Web
: Trunk
: PC Linux
: --- normal
: ---
Assigned To: Bugzilla
:
:
:
:
  Show dependency treegraph
 
Reported: 2012-12-22 02:34 EST by Daniel Lo Nigro
Modified: 2012-12-23 08:09 EST (History)
1 user (show)

See Also:
Tags:
Test Case URL:
External Submit: ---


Attachments
Example project demonstrating the issue (1.06 MB, application/x-gzip)
2012-12-22 02:34 EST, Daniel Lo Nigro
Details

Description Daniel Lo Nigro 2012-12-22 02:34:15 EST
Created attachment 3123 [details]
Example project demonstrating the issue

Given routes like this:

// Blog home page - Don't include page number in URL for first page
routes.MapRoute(
    name: "BlogHome",
    url: "blog",
    defaults: new { controller = "Home", action = "BlogIndex", page = 1 }
);
routes.MapRoute(
    name: "BlogHomePage",
    url: "blog/page-{page}",
    defaults: new { controller = "Home", action = "BlogIndex" },
    constraints: new { page = @"\d+" }
);

Whenever page=1 is used in the route, it should resolve to /blog, and whenever
any other number is used, it should resolve to /blog/page-x. That is, the
following Razor (.cshtml) view:
@Url.Action("BlogIndex", "Home", new { page = 1 });
@Url.Action("BlogIndex", "Home", new { page = 2 });

Should display the following:
/blog/page-1
/blog/page-2

This works in Microsoft .NET, but Mono appears to be ignoring the first route
and is outputting the following:
/blog/page-1
/blog/page-2

Another issue I've encountered is with the following routes:
routes.MapRoute(
    name: "BlogAdminPostsPublished",
    url: "blog/admin/posts/published",
    defaults: new { controller = "Home", action = "Posts", published = true }
);
routes.MapRoute(
    name: "BlogAdminPostsUnpublished",
    url: "blog/admin/posts/unpublished",
    defaults: new { controller = "Home", action = "Posts", published = false }
);

UrlHelper.Action is not using these routes in Mono - The following:
@Url.Action("Posts", "Home", new { published = true })
@Url.Action("Posts", "Home", new { published = false })

Should output this:
/blog/admin/posts/published
/blog/admin/posts/unpublished

But it is outputting this:
/Home/Posts?published=True
/Home/Posts?published=False

I've attached a test project which demonstrates this issue. This app runs under
Mono 3.0 (via XSP) and on Windows via IIS or Cassini.
Comment 1 Daniel Lo Nigro 2012-12-22 02:35:25 EST
Sorry, for the first one, I meant that the output should be as follows:
/blog
/blog/page-2
Comment 2 Daniel Lo Nigro 2012-12-22 22:16:32 EST
I've fixed this but Github is currently down. I'll submit my fix as a pull
request once Github is up again.
Comment 3 Daniel Lo Nigro 2012-12-23 00:25:16 EST
Patch submitted via Github: https://github.com/mono/mono/pull/526

Note You need to log in before you can comment on or make changes to this bug.