Reputation: 2807
I need to post data to a form programatically but the fields of the form are saved in the session of php. I am using C# in order to post the data to the form but it redirects me to the same page because of the aformentioned issue.
Upvotes: 1
Views: 386
Reputation: 840
Strange coincidence. I've got something like that ...
class CookieAwareWebClient : WebClient
{
public CookieContainer Cookies { get; private set; }
public CookieAwareWebClient()
{
Cookies = new CookieContainer();
}
protected override WebRequest GetWebRequest(Uri address)
{
var request = base.GetWebRequest(address) as HttpWebRequest;
if (request != null)
{
request.CookieContainer = Cookies;
return request;
}
return null;
}
}
Upvotes: 1