ivaylokenov / AspNet.Mvc.TypedRouting

A collection of extension methods providing strongly typed routing and link generation for ASP.NET Core MVC projects.
https://mytestedasp.net/
MIT License
485 stars 36 forks source link

RedirectToAction on another controller clears action parameters #34

Open viktorsykora opened 5 years ago

viktorsykora commented 5 years ago

Hi,

Just found a possible issue when calling RedirectToAction with target action on another controller.

Here is the code:

public class HomeController : Controller
{
    public IActionResult Index()
    {
        return this.RedirectToAction<TestController>(c => c.Test(9));
    }
}
public class TestController : Controller
{
    public IActionResult Test(long id)
    {
        return View();
    }
}

The id parameter in Test action should be 9, but it's defaulted to 0. When I move the Test action into HomeController then it starts to work just fine.

Any suggestions appreciated, Thanks

ivaylokenov commented 5 years ago

Hi @viktorsykora! Which version of ASP.NET Core are you using?

viktorsykora commented 5 years ago

It's ASP.NET Core 2.1.1.

ivaylokenov commented 5 years ago

Hi, thank you for your issue. Since I am overwhelmed with my other project https://github.com/ivaylokenov/MyTested.AspNetCore.Mvc, I did not have a lot of time to support this one. Will try to publish a new package during the weekend. Thank you for your patience!