zoukankan      html  css  js  c++  java
  • MVC后台的几种跳转方法

    //当服务器执行到Response.Redirect语句时,会立即中断页面的生命周期,直接向客户端返回信息,让客户端进行重定向操作。302(暂时重定向)

    Response.Redirect("User/News");  //或者return Redirect("User/News");

    //当服务器执行到Response.RedirectPermanent语句时,会立即中断页面的生命周期,直接向客户端返回信息,让客户端进行重定向操作。301(永久重定向)

    Response.RedirectPermanent("User/News");//或者return RedirectPermanent("User/News");

    //直接跳转到视图

    return View("NoticeForm", notice);

    //跳转到控制器对应的方法

    RedirectToAction(string ActionName);  //跳转到同一Controller 里面的不同Action,如:HomeController里面的不同页面跳转到Index页面,RedirectToAction("Index");

    RedirectToAction(string ActionName, object viewData);  //跳转到同一Controller 里面的不同Action,含参数,如:HomeController里面的不同页面跳转到Index页面,并传递msg="操作成功",RedirectToAction("Index",new {msg="操作成功"});

    RedirectToAction(string ActionName, string ControllerName);  //跳转到不同Controller 里面的不同Action,如:其他Controller里面的页面跳转到HomeController里面的Index页面,RedirectToAction("Index","Home");

    RedirectToAction(string ActionName, string ControllerName, object viewData);  //跳转到不同Controller 里面的不同Action,含参数,如:其他Controller里面的页面跳转到HomeController里面的Index页面,并传递msg="操 作成功",RedirectToAction("Index","Home",new {msg="操作成功"});

  • 相关阅读:
    warning C4018: “<”: 有符号/无符号不匹配
    安装VS提示系统找不到指定路径
    C#调用非托管dll
    指针转引用
    C语言文件操作fclose在NDK引起的BUG
    ADT开发AndroidManifest.xml file missing错误
    利用Visual GDB在Visual Studio中进行Android开发
    OpenCv实现两幅图像的拼接
    C++读取文件夹中所有的文件或者是特定后缀的文件
    WORD2007多级列表
  • 原文地址:https://www.cnblogs.com/hucaihao/p/3516999.html
Copyright © 2011-2022 走看看