I have an ajax form:
@model Site.Models.ChangeModel
@using (Ajax.BeginForm("ChangePassword", "Account", new AjaxOptions { HttpMethod = "POST", UpdateTargetId="result" }, new { @class = "form-horizontal", role = "form", id = "changePasswordForm" }))
{
<div id="result"></div>
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, Base.ChangesNotSubmitted, new { @class = "alert alert-danger" })
@Html.EditorFor(m => m.ChangePasswordModel.OldPassword)
@Html.EditorFor(m => m.ChangePasswordModel.Password)
@Html.EditorFor(m => m.ChangePasswordModel.ConfirmPassword)
<div class="form-group">
<div class="col-sm-offset-6 col-sm-2">
<button type="submit" class="btn btn-primary">@Base.ChangePassword</button>
</div>
</div>
}
With this action
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult ChangePassword(ChangePasswordModel model)
{
bool changed=false;
if (ModelState.IsValid)
{
var result = UserManager.ChangePassword(User.Identity.GetUserId(), model.OldPassword, model.Password);
if (result.Succeeded)
{
changed = true;
}
}
return Content("changed");
}
The form is located in the action Index, and i don't have view for ChangePassword!
After submitting the sform I get:
- A blank page with content i've sent
- Url is changed to .../ChangePassword?length=7 (before it was /index)
I have no idea where this length parameter comes from.
So my question is how to stay on the same view and to get the result in the correct div?
And anyone any idea where the parameter length comes from, i already has this issue few times with it.