views:

22

answers:

1

Since we can't post data to cross domains, I want to post the data to my aspx page and a code-behind code will take the data and submit to cross domain (which is not being operated by me, so I don't have permission to modify source code for jsonp) and also the website to which I pass my post data is also returning a cookie which includes shopping cart info and I need to store it on my local browser cache as well.

Can you provide me some code on how to accomplish that?

Thanks..

What I know is I need to use WebResponse and WebRequest classes for that manner.

+2  A: 

You could use WebClient for that matter:

using (var client = new WebClient())
{
    // Define data to be posted
    var values = new NameValueCollection
    {
        { "key1", "value1" },
        { "key2", "value2" },
    };

    // Send the POST request
    byte[] result = client.UploadValues("http://foo.com", values);

    // This will contain the cookie being set
    string cookie = client.ResponseHeaders[HttpResponseHeader.SetCookie];
}
Darin Dimitrov
It didn't work for my case.
Braveyard
Well, you could probably have said what didn't work, what is your case, etc...
Darin Dimitrov