ASP.NET MVC的 Action跳转方法归纳部分

版权声明:转载请备注加链接原文,重写请修改加备注链接,谢谢 https://blog.csdn.net/weixin_43972758/article/details/86229519

action跳转分类

一、在同一控制器(Controllers)下的action跳转(不带参)

1.return Redirect(“Index”);Index本controller下,ActionResult的方法名称
2.return View(“Index”); *直接显示对应的页面Index *
3.return View() ;
4.RedirectToAction(“Index”);
5.return PartialView(“model”)* 部分视图:一般传递参数为一模型集合,实现页面显示不同表格切换*

二、在同一控制器(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:参数和内容

C#将Excel表格内容导入数据库–ASP.NET MVC

JQuery ajax 实现关闭弹窗,刷新列表

jQuery实现checkbox多选,单选与数据库交互传值,赋值整理

C# String字符串方法的使用归纳(直观,粗暴)

猜你喜欢

转载自blog.csdn.net/weixin_43972758/article/details/86229519