1

I have read many SO questions about the session issues within iframe but it doesn't seem to be the exact answer for the problem I'm having.

I have a php site which displays my .aspx sites within iframe. In Default.aspx, I get data passed from the parent (php) site and store it in a session variable as follows:

var c = HttpContext.Current;
string name1 = c.Request.Form["FirstName"];    
string name2 = "Nancy";

Session["name1"] = name1;
Session["name2"] = name2;

lblTest1.Text = "name1 = " + Session["name1"];
lblTest2.Text = "name2 = " + Session["name2"];

the print result is:

name1 = John
name2 = Nancy

The problem is, Session["name1"] loses its value but Sessoin["name2"] still holds its value after postback.

I try to print both names in the next page like this:

lblTest1.Text = "name1 = " + Session["name1"];
lblTest2.Text = "name2 = " + Session["name2"];

and the result is:

name1 = //blank
name2 = Nancy

I tried adding this in Session_Start

if (Request.IsSecureConnection)
{
    Response.Cookies["ASP.NET_SessionID"].Secure = true;
}

and also tried Session Variables not saved when page is in an iFrame, but this problem occurs in any browsers (IE, FF, Chrome).

The value of name1 comes from the parent site but is it that storing it in a session doesn't work?

Community
  • 1
  • 1
kabichan
  • 1,063
  • 4
  • 19
  • 49
  • 1
    You may have some other bug, like for example this code `c.Request.Form["FirstName"];` are you sure that you get something there ? – Aristos Apr 02 '14 at 20:45
  • Yes, I'm getting `"John"` from `c.Request.Form["Firstname"]` – kabichan Apr 02 '14 at 20:46
  • Yes, but you maybe delete it after that, try to add a simple string to see if pass. – Aristos Apr 02 '14 at 20:47
  • The php site is written by someone else so I can't change the value to pass. Once I get the value I stored it `string name1 = c.Request.Form["FirstName"];`, so even if I delete the value in `c.Request.Form["Firstname"]` shouldn't it be already stored in `name1`? Sorry, maybe I'm not understanding your suggestion.. – kabichan Apr 02 '14 at 20:54

0 Answers0