C# Programming
10-09-2009, 04:10 AM
Hi,
I'm trying to process the HTML source code from a certain web page.
This web page has security enabled, using a Username & a password.
I'm using the following method to try to access the page:
public static string GetHtmlPageSource(string url, string username, string password)
{
WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential(username, password);
try
{
using (Stream stream = wc.OpenRead(new Uri(url)))
{
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
catch (WebException e)
{
//Error handeling
return e.ToString();
}
}
This doesn't work however, I seem to be stuck at the logon page. I'm not able to pass the user security.
Anyone has an idea?
I'm trying to process the HTML source code from a certain web page.
This web page has security enabled, using a Username & a password.
I'm using the following method to try to access the page:
public static string GetHtmlPageSource(string url, string username, string password)
{
WebClient wc = new WebClient();
wc.Credentials = new NetworkCredential(username, password);
try
{
using (Stream stream = wc.OpenRead(new Uri(url)))
{
using (StreamReader reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
catch (WebException e)
{
//Error handeling
return e.ToString();
}
}
This doesn't work however, I seem to be stuck at the logon page. I'm not able to pass the user security.
Anyone has an idea?