如何使用 RedirectToAction 方法添加查询字符串值? [英] how to add querystring values with RedirectToAction method?

查看:28
本文介绍了如何使用 RedirectToAction 方法添加查询字符串值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 asp.net mvc 中,我正在使用此代码:

In asp.net mvc, I am using this code:

RedirectToAction("myActionName");

我想通过查询字符串传递一些值,我该怎么做?

I want to pass some values via the querystring, how do I do that?

推荐答案

任何不属于路由的值都将用作查询字符串参数:

Any values that are passed that aren't part of the route will be used as querystring parameters:

return this.RedirectToAction
  ("myActionName", new { value1 = "queryStringValue1" });

会回来:

/controller/myActionName?value1=queryStringValue1

假设没有名为value1"的路由参数.

Assuming there's no route parameter named "value1".

这篇关于如何使用 RedirectToAction 方法添加查询字符串值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆