Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AcceptVerbsAttribute in asp.net core

I need to write an action method which should respond to both Http get and Http post verbs in asp.net core MVC.I tried the following but it did not work and actually the acceptverbs attribute does not accept HttpVerbs.Get | HttpVerbs.Post) as it would do in MVC 5. So can someone help with this?

[AcceptVerbs(HttpVerbs.Get | HttpVerbs.Post)]
public IActionResult BatchGroupDetails(int id)
{
}
like image 818
Patric Johnson Avatar asked Nov 04 '25 21:11

Patric Johnson


1 Answers

Have you tried this way? It works for me.

[HttpPost()]
[HttpGet()]
public IActionResult Index()
{
    ...
}
like image 167
Grzegorz Brzęczyszczykiewicz Avatar answered Nov 07 '25 11:11

Grzegorz Brzęczyszczykiewicz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!