문제

Can you help me interpret this piece of code? What happens after the user clicks Log In?

@using (Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })) 
{
<fieldset>
    <legend>Log in Form</legend>
    <ol>
        <li>
            @Html.LabelFor(m => m.UserName)
            @Html.TextBoxFor(m => m.UserName)
            @Html.ValidationMessageFor(m => m.UserName)
        </li>
        <li>
            @Html.LabelFor(m => m.Password)
            @Html.PasswordFor(m => m.Password)
            @Html.ValidationMessageFor(m => m.Password)
        </li>            
    </ol>
    <input type="submit" value="Log in" />
</fieldset>   
}

Btw, could not find google documentation on Html.BeginForm at all.

도움이 되었습니까?

해결책

The form is submitted to the same URL that rendered it.

As specified in the documentation, the overload used is BeginForm(this HtmlHelper helper, object routeValues), so the value of ReturnUrl will be passed as a route value. What happens to that value depends on the application's routes - typically it will be appended to the request URL as a query string parameter.

Try implementing the view and examining the rendered markup.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top