zoukankan      html  css  js  c++  java
  • c# mvc action 跳转方式

    c# 的mvc 有很多的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();//直接显示页

  • 相关阅读:
    笔记-归并排序
    Repeated Substring Pattern
    Assign Cookies
    Number of Boomerangs
    Paint Fence
    Path Sum III
    Valid Word Square
    Sum of Two Integers
    Find All Numbers Disappeared in an Array
    First Unique Character in a String
  • 原文地址:https://www.cnblogs.com/wfy680/p/14536828.html
Copyright © 2011-2022 走看看