zoukankan      html  css  js  c++  java
  • ASP.NET MVC RedirectToRoute类[转]

    Controller类中与RedirectToRoute相关的方法有两个:RedirectToAction()和RedirectToRoute()。

      1、RedirectToAction()

      ◊ 转到同一个Controller的另外一个Action

    protected internal RedirectToRouteResult RedirectToAction(string actionName);
    public ActionResult Index()
    {
        return RedirectToAction("List");
    }

      ◊ 转到指定Controller的Action

    protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName);
    public ActionResult Index()
    {
        return RedirectToAction("List", "Member");
    }

      ◊ 转到MemberController的List Action方法中,并加上"page"这个RouteValue值

    protected internal RedirectToRouteResult RedirectToAction(string actionName, string controllerName, object routeValues);
    public ActionResult Index()
    {
        return RedirectToAction("List", "Member", new { page = 2 });
    }

      2、RedirectToRoute()

      ◊ 转到同一个Controller的另外一个Action

    protected internal RedirectToRouteResult RedirectToRoute(object routeValues);
    public ActionResult Index()
    {
        return RedirectToRoute(new { action = "List" });
    }

      ◊ 转到指定Controller的Action

    public ActionResult Index()
    {
        return RedirectToRoute(new { controller="Member", action = "List" });
    }

      ◊ 转到MemberController的List Action方法中,并加上"page"这个RouteValue值

    public ActionResult Index()
    {
        return RedirectToRoute(new { controller = "Member", action = "List", page = 3 });
    }
  • 相关阅读:
    android自定义View之NotePad出鞘记
    一个电商项目的Web服务化改造
    一个电商项目的Web服务化改造
    POJ 2886 Who Gets the Most Candies?
    POJ 2392 Space Elevator
    POJ 1276 Cash Machine
    POJ 2063 Investment
    CodeForces 159c String Manipulation 1.0
    Gym
    FZU 1921 栀子花开
  • 原文地址:https://www.cnblogs.com/xzitluyang/p/6042245.html
Copyright © 2011-2022 走看看