The initial goal is to send the data entered in the form to the server, and, if the data is correct, give the appropriate page, if not, reload the same one.
I have a form in cshtml:
@using (Html.BeginForm("DataCheck", "Home")) { <div class="inputGroup inputGroup1"> <label id="adminLogin" for="adminlogin">Логин</label> @Html.TextBox("adminlogin", null, new { @class = "login" }) <span class="indicator"></span> </div> <div class="inputGroup inputGroup2"> <label id="adminPassword" for="adminpassword">Пароль</label> @Html.Password("adminpassword", null, new { @class = "password" }) </div> <div class="inputGroup inputGroup3"> <input type="submit" id="log_in" value="Войти" /> <p> @ViewBag.Text </p> </div> <div class="login-close-popup js-login-close-campaign"></div> } Here is the "DataCheck" method in the controller:
[HttpPost] public ActionResult DataCheck (string adminlogin, string adminpassword) { if(adminlogin == "Kate_adm" && adminpassword == "1234520") { return View("Admin_Page"); } else { ViewBag.Text = "Неверно введены данные."; return View("Index"); } } As a result, whatever data is entered into the form, the page simply reloads, and something like this appears in the address bar:
http://localhost:49477/?adminlogin=Kate_adm&adminpassword=1234520 I did something wrong, but I do not know what. Perhaps this question will seem silly, but I just recently started to get acquainted with MVC.