-
Notifications
You must be signed in to change notification settings - Fork 122
Routing (Get(int id)) has been broken in latest RC2 #233
Comments
Routing does not maps to action if first one matched path but did not matched HTTP method or constraint. Simple controller: public class HomeController : Controller
{
[HttpGet]
public IActionResult Index()
{
return Content("Index");
}
[HttpGet("{id:int}")]
public IActionResult Item(int id)
{
return Content(id.ToString());
}
[HttpGet("{name}")]
public IActionResult Item(string name)
{
return Content(name);
}
} Everything work OK in rc1-final, bun in Microsoft.AspNet.Routing v1.0.0-rc2-15978 request |
I'll take a look at this tomorrow and figure out what's going on. We didn't make any major changes is in this area in RC1 so the issue is likely something outside of MVC - you are welcome to say 'told ya so' if I'm wrong 😆 Are you running in IIS? Are you using kestrel/weblistener? Linux/windows/coreclr/desktop/mono? Does your app have a base-path? Can you provide your complete startup code? |
The test project was created in Visual Studio 2015 via Wizard and then ported to latest RC2. Steps to reproduce the issue:
[HttpPost("{asfile:bool}")] From the log, it seems Attribute Routing was changed in some way recently, so I guess those changes broke asp.net 5 routing. |
Yes, despite my assertions, we actually made a lot of changes in this area in RC2. I'll figure out the issue, thanks 👍 |
The bug is here: https://github.com/aspnet/Routing/blob/dev/src/Microsoft.AspNet.Routing/AttributeRouting/TreeRouter.cs#L193 This should be a The effect is that if we ever fail to match a route because of a constraint, we halt instead of continuing and trying other routes. It's likely we have the positive test for this (route with constraints tried before route without), but not the negative. |
Fixed by 123eaf2 |
It seems routing has been broken in latest RC2. When the following controller is run on RC2, method 'Get(int id)' receives no hit. If you enter 'http://localhost:9941/api/values/1' or the like in Edge or IE, it reports error 404.
If we remove method 'Post(bool asfile, [FromBody]string sRegData)', 'Get(int id)' will get hits as usual.
I think this is a bug introduced in latest RC2 because I can run the above controller on RC1 final and RC2 weeks ago without any issue.
The text was updated successfully, but these errors were encountered: