Cannot use default credential in proxy to access external web page

Joined
May 8, 2008
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top