部分视图和ajax

I want to update Partial View via ajax, but it does not work. Look at this model class:

   public class LogOnModel
    {
        [Required]
        [Display(Name = "User name")]
        public string UserName { get; set; }

        [Required]
        [DataType(DataType.Password)]
        [Display(Name = "Password")]
        public string Password { get; set; }

        [Display(Name = "Remember me?")]
        public bool RememberMe { get; set; }

        public bool IsLoggedIn { get; set; }

        public string ReturnUrl { get; set; }
    }

the following view:

@model ITW2012Mobile.ViewModels.LogOnModel
<div id='LogOn' style="background-color: White;">
    @using (Ajax.BeginForm("LogOnAjax", "Home", new AjaxOptions { UpdateTargetId = "LogOn", OnSuccess = "logInComplete" }))
    { 
        ITW2012Mobile.ViewModels.LogOnModel m = Model;
        @Html.EditorFor(model => model.IsLoggedIn)
        @Html.EditorFor(model => model.ReturnUrl)
        <div>
            @Html.ValidationSummary()
        </div>
        <div>
            @Html.LabelFor(model => model.UserName)
            @Html.EditorFor(model => model.UserName)
        </div>
        <div>
            @Html.LabelFor(model => model.Password)
            @Html.EditorFor(model => model.Password)
        </div>
        <div>
            <input type="submit" value="Login" />
        </div>
    }
</div>

and the following controller class:

public ActionResult LogOnAjax(LogOnModel model)
{
    if (!User.Identity.IsAuthenticated)
    {
        if (ModelState.IsValid)
        {
            if (Membership.ValidateUser(model.UserName, model.Password))
            {
                FormsAuthentication.SetAuthCookie(model.UserName, model.RememberMe);
                model.IsLoggedIn = true;
                model.ReturnUrl = Url.Action("Index", "Home"); 
            }
            else
            {
                ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }
        }

        // If we got this far, something failed, redisplay form
        return PartialView("PartialViewAjaxLogOn", model);
    }
    else
    {
        return PartialView("PartialViewLogOut");
    }
}

even when username/password are correct and IsLoggedIn = true and ReturnUrl!=empty view shows empty fields for these variables (but debugger shows values inside). Why and how to make it correctly?

Try clearing the values you are modifying in your action from modelstate or if you use them in html helpers the old values will be used:

ModelState.Remove("IsLoggedIn");
model.IsLoggedIn = true;
ModelState.Remove("ReturnUrl");
model.ReturnUrl = Url.Action("Index", "Home"); 

Also bear in mind that upon successful authentication and cookie emission you should not display a view (partial in your case). You should redirect so that the authentication cookie is sent by the client on the subsequent request. You should redirect to the return url. But since you are doing this using AJAX you should probably send some indication to the client that the authentication was successful so that you can redirect on the client.