In c# you do not need to use winInet.dll directly, there are several .NET classes you can use:WebClient
] is a wrapper around wininet and probably easiest to use. WebRequest
] and it's descendents will give you more control over creating requests and processing response.
In your case problem seems to be that you need to handle cookies so the server you're connecting to can use session.
WebClient class does not handle cookies by default but you can extend it:
public class WebClientEx : WebClient
private readonly CookieContainer _Container = new CookieContainer();
protected override WebRequest GetWebRequest(Uri address)
WebRequest request = base.GetWebRequest(address);
HttpWebRequest webRequest = request as HttpWebRequest;
if (webRequest != null)
webRequest.CookieContainer = _Container;
and use WebClientEx instead of WebClient.