• RedirectToAction、Redirect、Return View的区别


    return RedirectToAction()

    RedirectToAction是从一个Action调到另一个Action,在后台做跳转。

    重定向到某个控制器的页面,可以传递参数。

    比如:return RedirectToAction(“view","controller" , new {param1=value1,param2=value2 });

    这样传递的参数,参数放在ViewData里面,前台获取参数的方式为:

    <input id="taskType" name="taskType" type="hidden" value='@ViewData["param1"]' />

    或者

    <input id="taskType" name="taskType" type="hidden" value='@Request.Params["param1"]' />

     

    return View() 

    服务器端产生数据,让一个View去显示的,即Return View是让服务器把指定的cshtml的内容运行渲染后给到浏览器

    可使用ViewData和ViewBag两种形式,只不过在前台获取参数的方式不同而已。

    若使用ViewBag的方式传递:

    则:后台:ViewBag.param1= value1;

    前台:<input id="taskType" name="taskType" type="hidden" value='@ViewBag.param1' />

    Response.Redirect()方法:

    Response.Redirect是给返回前台返回应答,前台根据应答的url进行跳转;让浏览器去访问另外一个页面
    https://www.cnblogs.com/wfy680/p/15413396.html

     

    Server.Trasfer

  • 相关阅读:
    github 代理加速
    centos系统语言设置为中文
    红帽 / CentOS安装Jenkins
    查看api有没有更新到位
    永久关闭Windows10或Windows11的系统自动更新
    api传文件连接超时
    docker日常使用
    开发者工具批量替换
    Linux常用工具安装
    office密钥
  • 原文地址:https://www.cnblogs.com/wfy680/p/15413392.html
Copyright © 2020-2023  润新知