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

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

问题描述

在asp.net mvc的,我用这code:

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

假设有一个名为值1

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

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

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