Input Controls on the ASP.NET MVC Home Page

I have an ASP.NET MVC 2 website in which I would like to place the input controls on the main page. I want any validation error messages to be displayed on the main page. How can I do it? If I do something like this:

<% using (Html.BeginForm("LogOn", "Account", FormMethod.Post))  {  %>

  <%= Html.LabelFor(d => d.UserName)%>:
  <%= Html.EditorFor(d => d.UserName)%>

  <%= Html.LabelFor(d => d.Password)%>:
  <%= Html.Password("Password")%>

  <input type="submit" value="Login" />

  <%= Html.ValidationSummary() %>

<% } %>

... the account controller method is simply called a fine. However, when I return View()from the method, I get an error message that does not have a view called LogOn. How to achieve the expected result.

+3
source share
2 answers

LogOn, , URL- , , .

+1

, : "LogOn" " " ""?

View() , , ( "LogOn" )

hmm... : ViewModel ? etc

URL- refferal .. / RedirectAction().. .

, :

  • User-Login-Control iframe. .

  • jQuery

    $. get (url, null, function (result) {           $ (LoginDiv).html();
          });

, PartialView ( "LogOn" );

, .

0

Source: https://habr.com/ru/post/1722658/


All Articles