I’m following this tutorial:
It describes a situation when a user click a button and then a function without an attribute is called.
But when a function with HttpPost attribute is added, this function is called and not the function without the attribute.
The button initiates Html.BeginForm() which creates a post request. So why did the function without the attribute got called?
A submit button will ALWAYS initiate a
HttpPostrequest.A hyperlink on the other hand (
atag), that points to an action will ALWAYS be aHttpGet.EDIT: I realise your confusion, see below to demonstrate what @RickAndMSFT is trying to say:
Given that we have the following action method:
This action will ONLY accept
HttpGetrequestsNOTE: If we take away the
HttpGetattribute, it will accept ALL Request Types.Therefore, if you have:
There is no need for a post method because the method above already accepts post requests. This is the case because the page in question isn’t actually modifying/saving/creating anything, it’s just listing data.