Passing active SessionID to a HttpWebRequest

  • Thread starter Thread starter michi
  • Start date Start date
M

michi

Hello there....

I try to call a aspx file within an running asxp file. The key thing
is that I need to pass the active ASP.NET_SessionID to this new aspx
file via HttpWebRequest.GetResponse Method. Then I want to read the
whole thing with a stream object.

The weird thing happen at Line 9, after the timeout (1sec) is over.
ASP.NET throws an timeout exeption. Even when I set the timeout to 5
min, ASP is waiting always until a timeout expires

If I implement a Try/Catch at line 9, after the timeout my debugger
jumps to the new aspx file where I set a breakpoint. Also it uses the
same session ID :)
But the "objResponse" in line 9 is set to NOTHING and all the
following code fail because of that.

What do I have to do that the GetResponse Method works properly.

Thanks

Michael



********************My Code********************

1 Dim objResponse As HttpWebResponse
2 Dim objRequest As HttpWebRequest
3 Dim sr As StreamReader
4 Dim result As String



'**1 Create the Request object******************
5 objRequest = System.Net.HttpWebRequest.Create("http://localhost/aidsgame/test_result.aspx")

'***2 Add the container with the active sessionID***
6 objRequest.CookieContainer = New System.Net.CookieContainer(50)
7 objRequest.CookieContainer.Add(New
System.Uri("http://localhost/aidsgame"), New
System.Net.Cookie("ASP.NET_SessionId",
Request.Cookies("ASP.NET_SessionId").Value))


8 objRequest.Timeout = 1000
9 objResponse = objRequest.GetResponse() <---throws timeout
exeption


10 sr = New StreamReader(objResponse.GetResponseStream())
11 result = sr.ReadToEnd()


' Close and clean up the StreamReader
sr.Close()

********************************************
 
michi said:
Hello there....

I try to call a aspx file within an running asxp file. The key thing
is that I need to pass the active ASP.NET_SessionID to this new aspx
file via HttpWebRequest.GetResponse Method. Then I want to read the
whole thing with a stream object.

The weird thing happen at Line 9, after the timeout (1sec) is over.
ASP.NET throws an timeout exeption. Even when I set the timeout to 5
min, ASP is waiting always until a timeout expires

If I implement a Try/Catch at line 9, after the timeout my debugger
jumps to the new aspx file where I set a breakpoint. Also it uses the
same session ID :)
But the "objResponse" in line 9 is set to NOTHING and all the
following code fail because of that.

What do I have to do that the GetResponse Method works properly.
[...]

Your code looks fine (although I would extract the session id from
Session.SessionID). Does the web request ever hit the second page?

Cheers,
 
Hello Joerg...
Does the web request ever hit the second page?

Yes it does. As soon the time out occurs in Line9, the debugger jumps
to the new aspx file. After processing the new aspx file all
processing is stoped.

I tried the same script on a different server and it also did not
work.

Thanks for helping

Michael


Joerg Jooss said:
michi said:
Hello there....

I try to call a aspx file within an running asxp file. The key thing
is that I need to pass the active ASP.NET_SessionID to this new aspx
file via HttpWebRequest.GetResponse Method. Then I want to read the
whole thing with a stream object.

The weird thing happen at Line 9, after the timeout (1sec) is over.
ASP.NET throws an timeout exeption. Even when I set the timeout to 5
min, ASP is waiting always until a timeout expires

If I implement a Try/Catch at line 9, after the timeout my debugger
jumps to the new aspx file where I set a breakpoint. Also it uses the
same session ID :)
But the "objResponse" in line 9 is set to NOTHING and all the
following code fail because of that.

What do I have to do that the GetResponse Method works properly.
[...]

Your code looks fine (although I would extract the session id from
Session.SessionID). Does the web request ever hit the second page?

Cheers,
 
michi said:
Hello Joerg...


Yes it does. As soon the time out occurs in Line9, the debugger jumps
to the new aspx file.

I guess that's a case where you just need to try things, for example hitting
the second page from a Windows or command line client application.

I guess the first page works fine with the WebRequest code removed?

Cheers,
 
Back
Top