Question:
Is there any way to assign two different routes (with parameters) to the same controller in an ASP.NET MVC 6 application?
I Tried:
I tried using multiple route attributes to the controller class and also to the individual actions, did not work.
Notes:
I am using ASP.NET Core 1.0 RC1.
The reason I want to do this is, I want the api to be compatible with the older version of our mobile app which use the old URL.
Example:
[Produces("application/json")]
[Route("api/v2/Log")]
/// The old route is "api/LogFile" which I want to be still valid for this controller.
public class LogController : Controller {
[HttpGet("{id}", Name = "download")]
public IActionResult GetFile([FromRoute] Guid id)
{
// ...
}
}
In the example above: api/LogFile/{some-guid}
is the old route and api/v2/log/download/{some-guid}
is the new route. I need both routes invoke the same action.