如何从一个Controller Action重定向到另一个动作..我正在使用这种方法RedirectToAction(" actionName"," controllerName");

时间:2014-12-03 05:56:06

标签: asp.net-mvc asp.net-mvc-4

我有一个家庭控制器并且在登录操作中如果我在登录方面取得了成功,我想转移到管理控制器的索引操作。我正在使用以下方法

  //return View("../Admin/Index"); 
   return RedirectToAction("Index", "Admin");

这两种方法对我都不起作用我仍然在家庭控制器的索引操作中

 public ActionResult Login(string userName, string password)
    {
        if (IsValid(userName, password))
        {
            //return View("../Admin/Index"); 
            return RedirectToAction("Index", "Admin");

        }
        else
        {
            ModelState.AddModelError("", "Login details are wrong.");
            return PartialView("_login");   
        }

    }

0 个答案:

没有答案