在 GET 请求之间保留 javascript 变量? [英] Persist javascript variables between GET requests?

查看:29
本文介绍了在 GET 请求之间保留 javascript 变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

允许使用 ASP .NET
允许将值存储在隐藏的输入字段中
不允许查询字符串
不允许 POST 请求

ASP .NET is allowed
Storing the values in hidden input fields is allowed
Query String is not allowed
POST request is not allowed

可以在 GET 请求之间存储 JS 变量吗?
我想在客户端使用 ClientScript.RegisterStartupScript 重新初始化它们

我可以为此使用 cookie 吗?
还有其他可能性吗?
发出请求时 cookie 存储在哪里?

It is possible to store JS variables between GET requests ?
I want to reinitialize them on the client using ClientScript.RegisterStartupScript

Can I use cookies for this ?
Are there other posibilities?
Where cookies are stored when Request is made ?

推荐答案

我可以为此使用 cookie 吗?

Can I use cookies for this ?

是的,请参阅此关于在 Javascript 中使用 cookie 的教程.

还有其他可能性吗?

如果不允许在请求的 URL 中附加任何内容,我将无法想出任何内容.

If you are not allowed to append anything the URL of your requests, I can't come up with any.

发出请求时 cookie 存储在哪里?

Where cookies are stored when Request is made ?

在 HTTP 请求头中.上述教程将告诉您如何从 Javascript 读取它们的值.在 ASP.Net 的服务器端,您可以使用 Request.Cookie["cookieName"] 读取 cookie 值,它返回一个 HttpCookie.

In the HTTP request header. The aforementioned tutorial will tell you how to read their values from Javascript. On the server side with ASP.Net, you can read cookie values using Request.Cookie["cookieName"] which returns an instance of HttpCookie.

这篇关于在 GET 请求之间保留 javascript 变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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