Created
December 20, 2015 02:28
-
-
Save robsmith1776/f9ce74e23917e55e8c09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebClientEx : WebClient | |
{ | |
private CookieContainer _cookieContainer = new CookieContainer(); | |
protected override WebRequest GetWebRequest(Uri address) | |
{ | |
WebRequest request = base.GetWebRequest(address); | |
if (request is HttpWebRequest) | |
{ | |
(request as HttpWebRequest).CookieContainer = _cookieContainer; | |
} | |
return request; | |
} | |
} | |
class Program | |
{ | |
static void Main() | |
{ | |
using (var client = new WebClientEx()) | |
{ | |
var response1 = client.DownloadString("https://myJazzServer.com:9092/jazz/authenticated/identity"); | |
var data = new NameValueCollection | |
{ | |
{ "j_username", "myUser" }, | |
{ "j_password", "MyPass" }, | |
}; | |
var response2 = client.UploadValues("https://myJazzServer.com:9092/jazz/authenticated/j_security_check", data); | |
Console.WriteLine(Encoding.Default.GetString(response2)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment