-
Notifications
You must be signed in to change notification settings - Fork 10k
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
CreatedAtAction & AcceptedAtAction Don't Work With Methods Whose Name Ends with "Async" #23582
Comments
which endpoint are you trying to post from html ? |
Just to be clear, the endpoint I'm hitting in postman is just |
I think there's a bug here @pranavkm |
|
Sorry if I'm misunderstanding what you guys are saying, just want to clarify a few things to make sure we're all on the same page. The routes that I'm trying to hit are GET I was able to find a workaround by setting the option I'd like to close by saying that imo #4849 was handled improperly. The person who posted the issue likely had a misunderstanding about MVC that should have been corrected, not worked around, MVC was working properly. The problem could have been solved by telling them that they should add the attribute Additionally, I just tried this, renaming an action from Index to IndexAsync and renaming the razor page as well results in 404's all round. To get the right page I have to return |
I'll try to explain what the exchange was all about @ConnerPhillis
change to:
Because the actual action name will be If the async suffix removal was a right or wrong design, I think I'm with you but that's another issue. I personally avoid the async suffix in my code, think it's a really bad design/practice. I would rather use Sync if I have a really weird need to provide a sync version of a natural async one. |
@Bartmax thanks for the clarification, I thought about that but I ended up deciding that I couldn't get on board with introducing magic constants everywhere I wanted to use an async method, plus I think I prefer < Core 3.0's behavior. As for the async suffix, I've always found it a useful flag to determine if I need to be using await or not. Design patterns are obviously out of scope here, but I find it nice to have a way to express that information when I first view the method's name. To each his own I guess 😄 |
That's totally fine! it's definitely a personal preference. When I said I also agree that |
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes. See our Issue Management Policies for more information. |
Describe the bug
When creating controller methods I often find myself using async / await. When I do, I usually have something in the method's name denoting this (e.g.
CreateUserAsync
) so I know to await the result of that method later on.I have possibly found a bug where including the word
Async
in an action causesCreatedAtAction
andAcceptedAtAction
to fail to find whatever method you intended to match, giving the stack trace provided in the Exceptions section](#To Reproduce
Sample controller for testing:
Exceptions (if any)
Further technical details
Sorry if there's documentation that I've missed about this or I've done something wrong, this was a three hour headache for me earlier today and I couldn't find anything that would provide a reason as to why it behaved this way. Thanks in advance!
The text was updated successfully, but these errors were encountered: