Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ServicePointManager.Expect100Continue = true;
- ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
- CookieCollection cookies = new CookieCollection();
- HttpWebRequest request = (HttpWebRequest)WebRequest.Create("my provider logon page here");
- request.CookieContainer = new CookieContainer();
- request.CookieContainer.Add(cookies);
- HttpWebResponse response = (HttpWebResponse)request.GetResponse();
- cookies = response.Cookies;
- string getUrl = "my provider logon page here";
- string postData = String.Format("UserName={0}&Password={1}&userType={2}&rememberMe={3}", "login", "password", "FON", "true");
- HttpWebRequest getRequest = (HttpWebRequest)WebRequest.Create(getUrl);
- getRequest.CookieContainer = new CookieContainer();
- getRequest.CookieContainer.Add(cookies);
- getRequest.Method = WebRequestMethods.Http.Post;
- getRequest.UserAgent = "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36";
- getRequest.AllowWriteStreamBuffering = true;
- getRequest.ProtocolVersion = HttpVersion.Version11;
- getRequest.AllowAutoRedirect = true;
- getRequest.ContentType = "application/x-www-form-urlencoded";
- byte[] byteArray = Encoding.ASCII.GetBytes(postData);
- getRequest.ContentLength = byteArray.Length;
- Stream newStream = getRequest.GetRequestStream();
- newStream.Write(byteArray, 0, byteArray.Length);
- newStream.Close();
- HttpWebResponse getResponse = (HttpWebResponse)getRequest.GetResponse();
- using (StreamReader sr = new StreamReader(getResponse.GetResponseStream()))
- {
- string sourceCode = sr.ReadToEnd();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement