Skip to content
This repository was archived by the owner on Dec 14, 2018. It is now read-only.
This repository was archived by the owner on Dec 14, 2018. It is now read-only.

Default for catchall segment doesn't work #2931

Closed
@Daniel15

Description

@Daniel15
[Route("Foo/{*path}")]
public ActionResult Foo(string path = "default")
{
    if (path == null)
    {
        return Content("NULL");
    }
    if (string.IsNullOrEmpty(path))
    {
        return Content("EMPTY");
    }
    return Content("Path: " + path);
}

If you hit /Foo/ on ASP.NET MVC 5, it outputs "Path: default". However, ASP.NET 5 + MVC 6 outputs "NULL". Hitting /Foo/Bar correctly displays "Path: Bar" on both versions. This is the same if you change the default to an empty string - ASP.NET MVC 5 returns "EMPTY" whereas MVC 6 returns "NULL".

I also tried [Route("Foo/{*path=default}")] which did not work either.

Wasn't sure whether to report this in the Routing repo or here; I've reported it here since I think catchall segments are an MVC thing (and also RouteAttribute is an MVC thing)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions