使用Mvc中的部分视图重定向到另一个页面 [英] redirct to another page using Partial view in Mvc
本文介绍了使用Mvc中的部分视图重定向到另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在Master页面上添加Login视图。我使用局部视图添加它。
I have need to add Login view on Master page. i add it using partial view.
public ActionResult Login()
{
return PartialView();
}
[HttpPost]
public ActionResult Login(login response)
{
string uname = response.uname;
string pwd = response.pwd;
login l = new login();
int i = l.loginuser(uname, pwd);
if (i > 0)
{
return RedirectToAction("Index", "Admin");
}
else
{
return View();
}
}
当它回发时显示错误:儿童行为不允许执行重定向操作。
请帮我解决这个问题
Thanx问候
when it post back then it show error: Child actions are not allowed to perform redirect actions.
Please help me for solve that Problem
Thanx with Regards
推荐答案
请为部分视图选择一个不同的名称,如_Login,然后尝试重定向。您无法在部分视图上执行重定向操作。 PartialView只是一些html的可重用部分。
希望这有助于
Please choose a different name for the partial view like _Login and then try to redirect . You can't perform redirect action over Partial View . PartialView nothing but some resusable portion of a html.
Hope this helps
这篇关于使用Mvc中的部分视图重定向到另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文