I've been looking really hard to answer what I thought would be such a simple question, but how do I call a function from the Controller of a page using an HTML form/button.
The end-goal here is to make an add-to-cart button, but I must firstly figure out how to make a button in the first place.
This is the most common method I saw people doing:
The function in my controller I want to run is as such:

and then in my Index.cshtml file I have this block of code:
@using (Html.BeginForm("PostTest", "Index", FormMethod.Post))
{
<input type="submit" name="submit" value="Test" />
}
and the button shows up as it should,

but when I press it...

It just redirects to a page with the name of the function i'm trying to call instead of actually running it. I clearly have a fundamental misunderstanding of how the buttons work, but this is the answer I keep finding online.
Debug.Writeis not executing? Did you try to debug? Do you have a view with name PostTest ?Html.BeginForm("PostTest", "Index"should haveSmoothiesinstead ofIndex. And yes, since you're are doingreturn View()it will try to load view with the same name as controller action. So you need to have view with the same name as action name. Or you can return some tiger view by specifying name in View(). Examplereturn View("some view");