0

I am using website which has some traffic values inside. When i connected to site(with any browser) it ask for pass and username. Even if i put true pass and username it is asking again pass and username. After putting pass and username second time with same username and pass, website giving access(i know this is web site issue but i need to resolve it in my code).

For this reason at my application side downloading empty files.Not giving any errors or something.

Here is my code:

try
{
     WebClient webClient = new WebClient();
     webClient.Credentials = new NetworkCredential("username", "pass");
     webClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompleted);
     webClient.UseDefaultCredentials = true;
     webClient.DownloadFileAsync(new Uri("http://examplewebsite.com/trafikdata/xml/speeds.xml"), @"speeds\" + CreateFilename());

}
catch (WebException Ex)
{
     btn_Update.Text = "UPDATE";
     Bekle.Visible = false;
     MessageBox.Show("Download Edilemedi!"+Ex.Message);
}

Is there a way to send credential second time or another way to get throught?

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
hkurt
  • 1
  • 1
  • Sure you are not just lacking an `await`? – Patrick Hofman Apr 08 '16 at 19:38
  • The title of this question and the actual question don't correlate. What is the question? – TEK Apr 08 '16 at 19:54
  • I couldnt find a proper name for title of question, for that i named like that. – hkurt Apr 09 '16 at 06:10
  • Question just typed when i try to access web site by any browser (manually) it is asking me credentials, even if i pass down true password and username, it asking credentials again after second entry then it allows me to access to the site. In code side when run it, it downloads an empty file. but i know after second credentials entry it will give me access. – hkurt Apr 09 '16 at 06:17

0 Answers0