本文介绍了使用模型作为剖析器将动作重定向到其他区域中的动作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在在Admin区域中,想要将值发送到Account Controller,这是默认区域中我如何发送

I am on Admin area now want to send the values to Account Controller which is in default area how i can send

ChangePasswordModel mode = new ChangePasswordModel();
                mode.ConfirmPassword = password;
                mode.NewPassword = password;
                mode.OldPassword = user.Password;
                return RedirectToAction("ChangePassword", "Account",new { area = '/' } , new {model = mode});

这是我要在帐户控制器中重定向我的代码的另一项操作

this is my other action in Account Controller where i want to redirect my code

[Authorize]
        [HttpPost]
        public ActionResult ChangePassword(ChangePasswordModel model)
        {
            if (ModelState.IsValid)
            {

                // ChangePassword will throw an exception rather
                // than return false in certain failure scenarios.
                bool changePasswordSucceeded;
                try
                {
                    MembershipUser currentUser = Membership.GetUser(User.Identity.Name, true /* userIsOnline */);
                    changePasswordSucceeded = currentUser.ChangePassword(model.OldPassword, model.NewPassword);
                }
                catch (Exception)
                {
                    changePasswordSucceeded = false;
                }

                if (changePasswordSucceeded)
                {
                    return RedirectToAction("ChangePasswordSuccess");
                }
                else
                {
                    ModelState.AddModelError("", "The current password is incorrect or the new password is invalid.");
                }
            }

            // If we got this far, something failed, redisplay form
            return View(model);
        }

推荐答案

对于RedirectToAction,它没有重载,它需要4个参数 .

There isn't an overload for RedirectToAction that takes 4 parameters.

尝试一下:

return RedirectToAction(
    "ChangePassword",
    "Account",
     new { area = "", model = mode });

这篇关于使用模型作为剖析器将动作重定向到其他区域中的动作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-13 15:44