views:

41

answers:

2

Hello,

i made some WebRequest's and got Responses to a site and succesfully posted data for 3 pages. Now the last page is a confirmation page and i need to make the user click the confirm button. But when i write response content to the browser like this

response = request.GetResponse() as HttpWebResponse;
dataStream = response.GetResponseStream();
reader = new StreamReader(dataStream);

responseFromServer = reader.ReadToEnd();
responseFromServer = responseFromServer.Replace(@"=""/", @"=""http://website.com/");
Page.Response.Write(responseFromServer);

web page redirects to logoff page after user clicked the button, because browser doesn't have the cookies and session variables. What i did above was just writing html to a page. I thought, maybe HttpContext.Current or WebClient classes can be useful but could not figure it out.

How can i make the browser to continue this session? how can i pass session variables and cache from response to browser?

Any help will be appreciated..

Sinan

A: 

If I understand your scenario, you are writing an ASP.NET page that in turn authenticates with another website on behalf of a user of your page. When this asp.net page gets a request from the user, it in turn sends a couple of request/responses to the backend webserver. At some point you want to finish the transaction to the backend server by first getting confirmation of the user of your page.

So, what is happening is that the session state is being lost when the confirmation request comes in. What you should do is to associate the user with a session and store your backend cookies (that were set in the CookieContainer) in the user's session. if there is only one webserver that is servicing the user, you can probably store it in a static hashtable/dictionary.

hope that helps.

feroze
A: 

I was making a request to a website. When website responses i was trying to write response content to page. i hoped that user could go on surfing that website but now i realize this is impossible because of security reasons. i cannot set session id (session cookie) for another domain. i tried to add a jsessionid cookie by javascript but access is denied..

Sinan