简体   繁体   中英

How to retrieve a session value from Javascript in another aspx.cs page?

I have used a session in Javascript as below.

var myvar = "Welcome"; '<%Session["Test"] = "' + myvar +'"; %>';

How to retrieve that session value in another aspx.cs page?

Thanks in advance!

Update the session value in hidden field in your JavaScript code.

And get the value from hidden value on the server side and update the session value.

Javascript:

var jsVar = '<%= Session["Test"].ToString() %>';

C#

string csVar = Session["Test"].ToString();

你认为这可能对你有帮助

var Session = '@HttpContext.Current.Session["Test"]';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM