This form instead using the "Verify function in my controllers goes to the subpage /Account/Verify
Form:
@using (Html.BeginForm("Verify", "Account", FormMethod.Post))
{
<span>Enter Your Email:</span>@Html.TextBoxFor(m=>m.Name)<br />
<span>Enter Your Password:</span>@Html.TextBoxFor(m=>m.Password)<br />
<input id="Submit" type="submit" value="submit" />
}
Method:
[HttpPost] public ActionResult Verify(Account acc)
{
connectionString();
con.Open();
com.Connection = con;
com.CommandText = "select * from Users where Name = '"+acc.Name+"' and password = '"+acc.Password+"'";
dr = com.ExecuteReader();
if (dr.Read())
{
con.Close();
return View("Home");
}
else {
con.Close();
return View("Privacy");
}
}
EDIT: Adding picture so the Controller and it’s location are visible
I feel like I tried everything rn and I’m out of ideas how could I do this
I wanted the form proceed and to be redirected to one of the subpages I’ve Pointed
2
Answers
it finally worked, this is how it should be:
Html.BeginForm("Verify", "Account", FormMethod.Post
So basically first goes method name and second in controller name, but I'm sure I've tried this couple of times, but it didn't work previously. Anyway the problem seems solved for now
Please try to mark your HttpMethod in controller.
Like:
Also in the browser please open developer tools windows (F12 or Right click and inspect will enough for it.) after then go to network tab. You can see the network requests on there. Just keep monitoring the network packages and press the form submit button then verify is your endpoint correct or not.