Bug 5283 - RouteCollection behavior differs from Microsoft .NET
Summary: RouteCollection behavior differs from Microsoft .NET
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: 2.10.x
Hardware: PC Windows
: --- normal
Target Milestone: Community
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-05-23 14:16 UTC by Michiel Overeem
Modified: 2016-11-10 13:18 UTC (History)
5 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments

Description Michiel Overeem 2012-05-23 14:16:50 UTC
The behavior of the RouteCollection differs from Microsoft's implementation. Causing URL's to be catched by the wrong handler.

Problem 1. The RouteCollection.Ignore method.


Example code:

private static void RegisterRoutes(RouteCollection routes) 
{
  routes.Ignore("{fileName}.command/{*pathInfo}");

  // other routes
}

On Microsoft .NET this rule causes url's like 
filename.command?a=b&x=y&z=h
to be ignored. On mono however, these url's are not ignored.

Changing the Ignore rule to
  routes.Ignore("{*allcommand}", new { allcommand = @".*\.command(/.*)?" });
causes it to work correctly.

Problem 2. The catch all route.

Example code:

private static void RegisterRoutes(RouteCollection routes) 
{
  routes.Add(new Route("{*path}", new HttpHandlerRouteHandler<SomeType>());

  // other routes
}

On Microsoft .NET this route catches
http://somedomain.com/ and http://somedomain.com/Home

On Mono however, I need to add the following rule to catch the first url:
  routes.Add(new Route("", new HttpHandlerRouteHandler<SomeType>());
Comment 1 Daniel Lo Nigro 2013-05-31 07:09:27 UTC
Are you still encountering this issue?
Comment 2 Michiel Overeem 2013-08-08 05:53:11 UTC
The differences between Mono and Microsofts implementation are still there.

But not all...

1) the route 
> routes.Ignore("{fileName}.command/{*pathInfo}");

now works the same on Mono and Microsoft

2) the route 
> routes.Add(new Route("{*path}", new HttpHandlerRouteHandler<SomeType>());

Still needs
> routes.Add(new Route("{}", new HttpHandlerRouteHandler<SomeType>());
on Mono

3) the route
>  routes.Ignore("Part/{*pathInfo}");
catches http://example.com/Part?arg=value with Microsofts implementation. On Mono however, those URL's are not catched.
Comment 3 Michiel Overeem 2013-08-08 06:02:13 UTC
This is all tested on Mono 3.2.1(MacOSX)

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