views:

23

answers:

1

This is C#.Net code:

How to share Cookie between 2 HttpWebRequest calls?

Details:

I am posting a form in first request from abc.com to xyz.com, this form contains some setting variables which are used by the system. lets say there is a input field in the form which sets the size of grid pages to be displayed in other pages.

Once i have updated the setings in previous request, i go to send a request to another page which shows off asp.net gridview/grid. The grid might contaian several pages and the page size should be the one which i set in previous request. But when i do this via HttpWebReeust it does not happen.

When i do it via browser, loading the setting page in the browser and then going to the grid view page... i see the page size is updated.

I want to achieve this via code. Sicne i am scraping this grid. i have to set page size or visit the gird pages one by one via code.

Or is it possible to set a cookie on 2nd request which is used to set in first request? It will be great if i go this way. any solution? All posts go to xyz.com from abc.com.

A: 

Cookies are controlled by your browser. If you were to open the same page in two different browsers, you will not see the cookies set by one browser in another.

HTTPWebRequest does not use any browser, so I don't think it will set any cookie at all.

You would probably need to store the settings at server side, maybe use a session.

Srikanth Venugopalan
All posts go to xyz.com from abc.com
SH