开发者

C# & Session Variables to iFrames

开发者 https://www.devze.com 2022-12-27 09:01 出处:网络
I am currently in C# and I have set Session variables on each page. The link to my Colo开发者_高级运维rbox is in the MasterPage, and on click opens up in> an iframe from a different page in a differe

I am currently in C# and I have set Session variables on each page.

The link to my Colo开发者_高级运维rbox is in the MasterPage, and on click opens up in> an iframe from a different page in a different folder

i.e. /admin/deals.aspx <-- iframed page in colorbox which needs SESSION /default.aspx <-- page with set SESSION

Is there a way I can pass this variable to the iframed page?


Session is relative to the user and site, not the page, so there is no reason why deal.aspx cannot access the Session variable set by default.aspx.

Alternatively, you could just pass the value on the querystring to the iframe. I am not a fan of this though as it means the user can tamper with the variable. Instead what i like to do is generate a random key (guids are good for this), use that as the Session key to store the variable, and then pass the key through on the querystring - still not foolproof, but it obfuscates things (the user cannot tamper with the variable value), and it prevents hardcoding of any keys in to your source code (as different pages need to know the same Session key).


I'm not really sure what you're asking - but let's just wing it;

Session variables are sessionwide and globally accessible, so when you've set the Session variable before opening your "colorbox" you should have access to that Session and therefor the enclosed variable.

On a sidenote however; do you really want to be using iFrames? (and Sessionvars for that matter).

0

精彩评论

暂无评论...
验证码 换一张
取 消