Skip to content
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 opened this issue Aug 7, 2015 · 2 comments
Closed

Default for catchall segment doesn't work #2931

Daniel15 opened this issue Aug 7, 2015 · 2 comments
Assignees
Milestone

Comments

@Daniel15
Copy link
Contributor

Daniel15 commented Aug 7, 2015

[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)

@Eilon Eilon added the bug label Aug 7, 2015
@Eilon Eilon added this to the 6.0.0-beta8 milestone Aug 7, 2015
@Eilon Eilon added the 1 - Ready label Aug 7, 2015
@Eilon
Copy link
Member

Eilon commented Aug 7, 2015

Certainly seems like a bug...

@rynowak
Copy link
Member

rynowak commented Aug 10, 2015

I'm wondering if the route value provider is missing a null-or-empty check. My understanding is that a catch-all segment will always have a value, even if it's the empty string.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants