我想[HttpPost]
从[HttpGet]
同一个控制器中的动作重定向到动作。
是否可以?
我试图不为登录重写相同的代码,因为它是一个复杂的,而不是典型的登录函数
这是我的代码:
[HttpGet]
public ActionResult Login(){
return View();
}
[HttpPost]
public ActionResult Login(LoginModel model)
{
//search user and create sesion
//...
if (registered)
{
return this.RedirectToAction("Home","Index");
}else{
return this.RedirectToAction("Home", "signIn");
}
}
[HttpGet]
public ActionResult signIn(){
return View();
}
[HttpGet]
public ActionResult signInUserModel model)
{
//Register new User
//...
if (allOk)
{
LoginModel loginModel = new LoginModel();
loginModel.User = model.User;
loginModel.password = model.password;
//next line doesn't work!!!!!
return this.RedirectToAction("Home","Login", new { model = loginModel);
}else{
//error
//...
}
}
任何帮助,将不胜感激。
谢谢