MVC4 - Register is partial view but on success should Redirect to a new Full Page
我有一个注册的部分视图。
1 2 3 4 | @using (Ajax.BeginForm("Register", new AjaxOptions { HttpMethod ="post", InsertionMode = InsertionMode.Replace, UpdateTargetId ="loginForm" })) |
控制者:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public ActionResult Register(RegisterModel model) { if (ModelState.IsValid) { Guid activationGUID = Guid.NewGuid(); if (UserManager.Register(model.Email, model.FullName, model.Password, activationGUID)) return RedirectToAction("Index","Dashboard"); else ModelState.AddModelError("","This email already exists"); } return PartialView(model); } |
出错,
我希望局部视图显示错误消息
控制器调用返回PartialView(模型); ......那很有效!
成功的话
我希望整个页面刷新(而不是在ajax调用上指定的UpdateTargetId)。
控制器调用返回RedirectToAction("索引","仪表板"); ......那就失败了!
相反,我将Dashboard表单插入到UpdateTargetID中。
我究竟做错了什么???
您需要使用