Previously as many articles mentioned that HttpGet is the default http method. For example if I have the following action method inside asp.net mvc web application, without any [httpGet] or [HttpPost]:-
Public ActionResult TestMethod(int I =0)
So I thought that this action method will be defined as Get action method, and will NOT be reachable if I send Posr request as follow “POST http://severname/test/TestMethod?i=1”
.
But seems that my action method will be available for both Post & Get requests, when I do not specify any http method. So as I know that HttpGet is the default , but seems this is not the case? Or I am missing something about what does httpGet is the default mean? Can anyone advice please? Thanks
HTTPPost method hides information from URL and does not bind data to URL. It is more secure than HttpGet method but it is slower than HttpGet. It is only useful when you are passing sensitive information to the server.
HttpGet and HttpPost both are the attributes used in asp.net mvc application. We use both attributes on action represents the http requests like whether it is get request or post request.
The MVC framework includes HttpGet, HttpPost, HttpPut, HttpDelete, HttpOptions, and HttpPatch action verbs. You can apply one or more action verbs to an action method to handle different HTTP requests. If you don't apply any action verbs to an action method, then it will handle HttpGet request by default.
HTTP GET: The Hypertext Transfer Protocol(HTTP) Get method is mainly used at the client (Browser) side to send a request to a specified server to get certain data or resources.
What I understand, By default It accept both type of request whether it is GET or POST. but when a action method is decorated with either [httpGet] or [httpPost] attribute then the action method accepts only those request method which define by attribute.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With