如何在会话变量中传递实际字符串并在aso.net中返回相同的字符串 [英] How to pass actual string in session variable and get back same string in aso.net

查看:102
本文介绍了如何在会话变量中传递实际字符串并在aso.net中返回相同的字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我需要在会话中存储一个sting并在javascript或jquery中返回相同的sting形式会话变量



例如,我会在会话变量中传递aravind / cad / file这个字符串,需要使用java脚本或jquery返回另一个页面。



什么我做了



服务器端代码是

  Dim  filepath  as  string =   aravind / cad / file 
会话( AfilePath)= filepath





和java脚本我得到这样的



  var  AfilePath = ' <%= Session( AfilePath)%>' 
alert(AfilePath);





ert消息我得到aravind-cad-file,所有/改为 - ,



注意:我不能将 - 转换为/ ,bcz有时字符串包含 - ,例如aravind / cad / file-png,所以这里如果将 - 转换为/则实际字符串会被错误地更改。



我需要加密和解密以传递会话值。





问候

Aravind

解决方案

HTMLEncode 可以帮到你 - http://msdn.microsoft.com/en-us/library/w3te6wfz(v = vs.110)的.aspx [<一个href =http://msdn.microsoft.com/en-us/library/w3te6wfz(v=vs.110).aspx\"target =_ blanktitle =New Window> ^ ]。

Hi
I need to store one sting in session and get back same sting form session variable in javascript or jquery

For e.g i will pass "aravind/cad/file" this string in session variable and need to get back in another page using java script or jquery.

What i did

in server side code is

Dim  filepath as string="aravind/cad/file"
Session("AfilePath") = filepath



and in java script i get like this

var AfilePath ='<%=Session("AfilePath")%>'
alert(AfilePath);



In alert message what i get "aravind-cad-file",all "/" change to "-",

Note: i cant convert "-" to "/" ,bcz sometime string contain "-" ,e.g "aravind/cad/file-png",so here if convert "-" to "/" then actual string is changed wrongly.

I need encrypt and decrypt for passing session values.


Regards
Aravind

解决方案

HTMLEncode should help you - http://msdn.microsoft.com/en-us/library/w3te6wfz(v=vs.110).aspx[^].


这篇关于如何在会话变量中传递实际字符串并在aso.net中返回相同的字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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