我想要一个设施,如果用户登录然后转到home / index
我不想用
return view('~/views/home/index');
我想将它重定向到我的web应用程序的home controller的actionresult索引(在asp.net mvc中)
如何在没有返回视图的情况下做到这一点();我想重定向他.
public actionresult login if(userlogin) { // goes to index page ? what i do here then user goes to index page of home controller } else { return view() }
解决方法
你可以重定向:
return RedirectToAction("index");
如果操作在不同的控制器上,也指定控制器名称:
return RedirectToAction("index","home");