Karnivaurus
Karnivaurus

Reputation: 24121

ASP.NET MVC: is calling an action Post or Get?

When you simply type a web address such as:

http://localhost/MyController/MyAction

this calls the MyAction function inside the MyController class.

My question: is this request an HttpPost, an HttpGet, or neither?

Upvotes: 0

Views: 38

Answers (4)

dknaack
dknaack

Reputation: 60466

Everytime you simple type in a url in the browser results in a GET request.

You can specifiy the accepted http method (verb) by using the several attributes.

  • [HttpPost]
  • [HttpPut]
  • [HttpGet]
  • [HttpDelete]

Upvotes: 1

DarthVader
DarthVader

Reputation: 55032

It is a HTTP GET by default.

[HttpPost]
public ActionResult Foo(){

}

This would be HTTPPOST.

Upvotes: 1

arserbin3
arserbin3

Reputation: 6148

It is a GET request.

POST requires are usually when a form is submitted

Upvotes: 0

Mattias Åslund
Mattias Åslund

Reputation: 3907

Its a GET request when the browser calls a url.

Upvotes: 1

Related Questions