zoukankan      html  css  js  c++  java
  • 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方法

  • 相关阅读:
    spring的了解以及简单框架的搭建
    动态代理
    struts2标签(转)
    使用OGNL表达式
    struts2 ValueStack
    struts2框架xml验证
    struts2 validate手动验证
    struts2自定义拦截器
    struts2文件上传
    当findById(Integer id)变成String类型
  • 原文地址:https://www.cnblogs.com/wangyinlon/p/10906790.html
Copyright © 2011-2022 走看看