Skip to content

RedirectToAction() makes the link to HttpPost action instead of GET #23089

@IgorXq

Description

@IgorXq

Hi !
For GET and POST methods with the same action names,

Microsoft.AspNetCore.Routing.DefaultLinkGenerator[105]
     [2020-06-18 14:05:13.651]: Link generation succeeded for endpoints 

generates lincorrect link that in my case eventually led to "too many redirects". (as far as I have investigated, it happens because the link is generated to HttpPost method instead of HttpGet when they both have the same name)

The issue happens for route patterns such as [Route("[controller]/{parameter}/action}")]

and does not happen for the route patterns like [Route("[controller]/action/{parameter}")]

Just to mention, HttpPost action has route pattern [Route("[controller]/action")] (parameter passes in ViewModel)

I have managed with the issue having renamed POST methods so that their names don't match with GET methods.

As for me, such behavior seems incorrect (as well as that RedirectToAction considers POST methods at all to generate links) or I might have lack of knowledge about ASP.Net core MVC routing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-mostThis issue impacts most of the customersarea-mvcIncludes: MVC, Actions and Controllers, Localization, CORS, most templatesbugThis issue describes a behavior which is not expected - a bug.feature-routingseverity-minorThis label is used by an internal tool

    Type

    No fields configured for Bug.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions