Sharing session value with HttpWebRequest - Timeout Issue


J

jonathan

Hi,

I've spend a lot of time on this problem without any change :
I have got 2 simples apsx page, in the first page the
Page_Load event put data in the session ;
later the on_click event of a button fire an HttpWebRequest to the second
page
with the idea to retrieve on the page_load of the second page the data in
the session.
to sum up : 1st page put data in session, make the httpWebRequest to the 2nd
page
2nd page : try to get the stored data in the session.

This is the different attempt of code i 've tested to perform this action,
the result was always the same. When i try to add sessionId Information (via
a cookieContainer or directly in the Header request) i get a timeout exception
System.Net.HttpWebRequest.GetResponse() and when i do the HttpWebrequest
without the session_id information i get the response immediatly but without
the
the session info :)

With is the code that try to perform the operation:

CookieContainer cookie = new CookieContainer();
HttpWebRequest req=(HttpWebRequest)WebRequest.Create("page2.aspx");
cookie.Add(new
System.Net.Cookie("ASP.NET_SessionId",HttpContext.Current.Session.SessionID));
req.CookieContainer = cookie;
WebResponse webResp=req.GetResponse();
webResp.Close();

or


HttpWebRequest req=(HttpWebRequest)WebRequest.Create("page2.aspx");
req.Headers.Add("Cookie",HttpContext.Current.Request.Headers["Cookie"]);
WebResponse webResp=req.GetResponse();
webResp.Close();

or

HttpWebRequest req=(HttpWebRequest)WebRequest.Create("page2.aspx");
req.Headers.Add("Cookie",HttpContext.Current.Request["sessionid"].ToString());
WebResponse webResp=req.GetResponse();
webResp.Close();

or

HttpWebRequest req=(HttpWebRequest)WebRequest.Create("page2.aspx");
req.Headers.Add("Cookie:
ASP.NET_SessionId="+HttpContext.Current.Session.SessionID);
WebResponse webResp=req.GetResponse();
webResp.Close();


The test case produce the same result when i had sessionid info
the request is well performed but the getResponse method fire a a timeout
exception !!!!!!

I 've got no more idea !!!!
Is the session is locked by the 1st page ???
Is the session_id information is enought to share the session with the two
page ???

I'm losted !

Thank's lot in advance for all your reply, ideas, track, help .....

Jonathan
 
Ad

Advertisements

P

Patrice

Both pages are on the same site ? If yes, yes the session is locked by the
first page when you attempt to access the same session using another page on
the same site.

Not sure what you are trying to do but using an ASCX control could be a
better design (you want to display some content from page2 inside page1
?)...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top