I have a web-application where I m automatically logged in with my Windows Credentials. I now want to consume information from this web-application, in a c# windows application using my Windows Account. Therefore I need to be able to get the session-cookie from this web-site. Here you can see a piece of my code, where I want to retrieve the cookie :
string URLAuth = extractParameterFromProperties("relatieBeheer_login_url");
WebClient webClient = new WebClient();
webClient.Credentials = CredentialCache.DefaultCredentials;
// webClient.UseDefaultCredentials = true;
byte[] responseBytes = webClient.DownloadData(URLAuth);
//byte[] responseBytes = webClient.UploadValues(URLAuth, "POST", formData);
string resultAuthTicket = Encoding.UTF8.GetString(responseBytes);
if(resultAuthTicket.Contains("Verkeerde combinatie gebruikersnaam")){
sessionCookie="NoSession";
}else{
WebHeaderCollection cookies = webClient.ResponseHeaders;
sessionCookie = cookies[HttpResponseHeader.SetCookie];
}
When I debug the application, I can see nothing is filled in the credentials : Domain, Username & Password are empty.
任何帮助都会受到欢迎。