Hi,
I have an ASP.NET 2.0 web app that needs to read the content of an external web page. I am able to access the web page if I use a proxy and my own credential. My web site uses Window Authentication and I set impersonate="true" in web.config. I would like my web app to use the login user's credential to access this external web page. However, it doesn't work.
Here is what I have that works:
Dim url As String = "http://www.google.ca"
Dim cred As New Net.NetworkCredential
cred.Domain = "myDomain"
cred.UserName = "myUserName"
cred.Password = "myPassword"
Dim proxy As New Net.WebProxy("http://proxyserver:8080/", True)
proxy.Credentials = cred
Dim aWebClient As New WebClient()
aWebClient.Proxy = proxy
Dim resultXml As String = aWebClient.DownloadString(url)
Here is what I had tried that don't work:
' proxy.Credentials = CredentialCache.DefaultCredentials
' proxy.UseDefaultCredentials = True
I've been searching the web for a long time but still couldn't get an answer. I will appreciate very much if someone can give me some suggestion.
Thanks very much.
I have an ASP.NET 2.0 web app that needs to read the content of an external web page. I am able to access the web page if I use a proxy and my own credential. My web site uses Window Authentication and I set impersonate="true" in web.config. I would like my web app to use the login user's credential to access this external web page. However, it doesn't work.
Here is what I have that works:
Dim url As String = "http://www.google.ca"
Dim cred As New Net.NetworkCredential
cred.Domain = "myDomain"
cred.UserName = "myUserName"
cred.Password = "myPassword"
Dim proxy As New Net.WebProxy("http://proxyserver:8080/", True)
proxy.Credentials = cred
Dim aWebClient As New WebClient()
aWebClient.Proxy = proxy
Dim resultXml As String = aWebClient.DownloadString(url)
Here is what I had tried that don't work:
' proxy.Credentials = CredentialCache.DefaultCredentials
' proxy.UseDefaultCredentials = True
I've been searching the web for a long time but still couldn't get an answer. I will appreciate very much if someone can give me some suggestion.
Thanks very much.