ASP.NET MVC的 ActionResult跳转视图方法

action跳转分类

一、在同一控制器(Controllers)下的action跳转(不带参) 1.return Redirect(“Index”);Index本controller下,ActionResult的方法名称 2.return View(“Index”); *直接显示对应的页面Index * 3.return View() ; 4.RedirectToAction(“Index”);。 二、在同一控制器(Controllers)下的action跳转(带参) 1.Response.Redirect(“Index?id=1”);//适用于本controller下的方法名称,可带参数。 Index?:ActionResult的方法名;id=1:参数和内容 * 三、跳转到不同控制器(Controllers)下的action(不带参) 1.RedirectToAction(ActionName,ControllerName) ActionName :ActionResult的方法名; ControllerName:控制器的名字 2.RedirectToRoute(new {controller=“Home”,action=“Index”}); Index :ActionResult的方法名; Home:控制器的名字 四、跳转到不同控制器(Controllers)下的action(带参) 1.RedirectToRoute(new {controller=“Home”,action=“Index”, id=param});/ Index :ActionResult的方法名; Home:控制器的名字; id=param:参数和内容

 

posted @ 2021-04-28 16:06  qingjiawen  阅读(895)  评论(0)    收藏  举报