首页 > 代码库 > Asp.Net MVC中Action跳转
Asp.Net MVC中Action跳转
首先我觉得action的跳转大致可以这样归一下类,跳转到同一控制器内的action和不同控制器内的action、带有参数的action跳转和不带参数的action跳转。
一、RedirectToAction("Index");//一个参数时在本Controller下,不传入参数。
二、RedirectToAction(ActionName,ControllerName) //可以直接跳到别的Controller.
三、RedirectToRoute(new {controller="Home",action="Index"});//可跳到其他controller
四、RedirectToRoute(new {controller="Home",action="Index", id=param});//可跳到其他controller,带参数。
五、Response.Redirect("Index?id=1");//适用于本controller下的方法名称,可带参数。
六、return Redirect("Index");//适用于本controller下的方法名称。
七、return View("Index"); //直接显示对应的页面 不经过执行Controller的方法。
八、return View("~/Views/Home/Index.aspx");//这种方法是写全路径,直接显示页面,不经过Controller方法
九、return View();//直接显示页面,不经过Controller方法
Asp.Net MVC中Action跳转
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。