Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
IgorXq opened this issue Jun 18, 2020 · 6 comments
Open

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

IgorXq opened this issue Jun 18, 2020 · 6 comments
Assignees
Labels
affected-most This issue impacts most of the customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. feature-routing severity-minor This label is used by an internal tool
Milestone

Comments

@IgorXq
Copy link

IgorXq commented Jun 18, 2020

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.

@javiercn javiercn added area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates feature-routing labels Jun 18, 2020
@javiercn
Copy link
Member

@IgorXq thanks for contacting us.

Can you provide a minimal repro project and host it somewhere public (GH repo or upload it as a zip here) so that can make sure we are not missing any detail?

@javiercn javiercn added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Jun 18, 2020
@IgorXq
Copy link
Author

IgorXq commented Jun 18, 2020

@javiercn thank you for a quick response.

Please check the demo project here

https://github.com/IgorXq/mvcdemo

If you run it, you can open the URL

http://localhost:5105/Dashboard/mytenant/same

that leads to the example page with correct and incorrect links formed by asp tag helpers.

The page http://localhost:5105/Dashboard/mytenant which should redirect to the url above, indeed ends up with "too many redirects" failure because of the link to the action

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Jun 18, 2020
@javiercn javiercn added investigate and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Jun 22, 2020
@javiercn javiercn added this to the Next sprint planning milestone Jun 22, 2020
@dotnet dotnet deleted a comment Jul 21, 2020
@dotnet dotnet deleted a comment Jul 21, 2020
@SteveSandersonMS SteveSandersonMS added affected-most This issue impacts most of the customers bug This issue describes a behavior which is not expected - a bug. severity-minor This label is used by an internal tool labels Oct 7, 2020 — with ASP.NET Core Issue Ranking
@ghost
Copy link

ghost commented Oct 9, 2020

We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process.

@ghost
Copy link

ghost commented Oct 12, 2022

Thanks for contacting us.
We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. Because it's not immediately obvious that this is a bug in our framework, we would like to keep this around to collect more feedback, which can later help us determine the impact of it. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@MackinnonBuck
Copy link
Member

I was able to reproduce this behavior. This seems like a bug IMO.

@muttonny
Copy link

Has this issue been resolved. And if so, which versions of .Net?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-most This issue impacts most of the customers area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates bug This issue describes a behavior which is not expected - a bug. feature-routing severity-minor This label is used by an internal tool
Projects
None yet
Development

No branches or pull requests

7 participants