简体   繁体   中英

Nested ASP.NET pages can't access each other's Session variables

I have an ASPX page which has an iFrame in it the source of which is an ASPX file as well, on the same domain. What I'm trying to do is - set a Session variable in the parent ASPX file and then access that variable in the file loaded in iFrame. However my inner file (loaded in the iFrame) does not seem to recognize the Session variable from the parent file and I'm simply getting an "Object reference not set to an instance of an object" error on the line where I'm trying to read the value of the Session variable. Could anybody give me a hint on what I'm doing wrong?

Thanks!

In what event of the parent page are you creating this session variable? I am pretty sure, it is a page-lifecycle problem. When you are hitting the session variable in the child page, the session variable is yet to be created by the parent page. put breakpoint on the session variable containing lines and see, which one is executed first.

Thanks for your responses. I actually resolved the issue. The case was that the folder where the parent file was located was an Application while the one which was the child (loaded in the iFrame) was outside of that Application. Simply removed the Application and it worked.

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