1存储的ActionResult一个js值在其他的ActionResult使用 [英] storing a js value from 1 ActionResult to use in another ActionResult

查看:97
本文介绍了1存储的ActionResult一个js值在其他的ActionResult使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制器,并在的ActionResult 取值之一,有被退回,我可以通过访问一个JavaScript值:

I've got a Controller, and in one of the ActionResults, there is a javascript value being returned that I can access via:

Request.QueryString["frequency"]

不过,我需要使用相同的变量在另一个的ActionResult 。我怎样才能做到这一点?

But I need to use that same variable in another ActionResult. How can I do this?

我知道,我不能设置一个

I know that I can't set a

string frequency = "";

在控制器的顶部,然后只在第1集的ActionResult

推荐答案

HTTP是无状态的,每个请求都有它自己的状态和控制器的实例。

HTTP is stateless, every request has it's own state and Controller instance.

您可以使用的TempData 它们使用会话,但你读它之后删除值。

You can use TempData which use Session but delete the value after you read it.

这篇关于1存储的ActionResult一个js值在其他的ActionResult使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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