michelle
michelle

Reputation: 2807

create session in c# to post data in form

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

Answers (2)

Oli
Oli

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

SLaks
SLaks

Reputation: 887489

Your question is fantastically vague.

You want a CookieContainer.

Upvotes: 0

Related Questions