469,636 Members | 1,634 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

httpwebrequest problems

I am using httpwebrequest to do a screen scrape.

This works great on my development box, but does not on the production box.

Here is the code.

Dim webRequest As HttpWebRequest = CType(webRequest.Create(LOGIN_URL),
HttpWebRequest)
webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy
webRequest.KeepAlive = False
Dim responseReader As StreamReader = New
StreamReader(webRequest.GetResponse.GetResponseStr eam)
Dim responseData As String = responseReader.ReadToEnd
responseReader.Close()

On my production box, I get this error:
The underlying connection was closed. Unable to connect to the remote server.

I have made sure I have .NET framework 1.1 SP 1 installed

I have added the following code to my web.config file

<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxy:port"
bypassonlocal="false"
/>
</defaultProxy>
</system.net>

And now I am at a loss?

Any thoughts?
Thanks

--
Tyler
May 3 '06 #1
2 3167
Um,
don't you want GetDefaultProxy, not
webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy

Its' DefaultProxy that you show in your config. You can also try more
specific code like this:

if (ConfigurationSettings.AppSettings["proxy"] != null)
{
WebProxy p = null;
string proxyAddressAndPort =
ConfigurationSettings.AppSettings["proxy"];
string proxyUserName =
ConfigurationSettings.AppSettings["proxyUserName"];
string proxyPassword =
ConfigurationSettings.AppSettings["proxyPassword"];
ICredentials cred;
cred = new NetworkCredential(proxyUserName, proxyPassword);
p = new WebProxy(proxyAddressAndPort, true, null, cred);
GlobalProxySelection.Select = p;
}
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tyler" wrote:
I am using httpwebrequest to do a screen scrape.

This works great on my development box, but does not on the production box.

Here is the code.

Dim webRequest As HttpWebRequest = CType(webRequest.Create(LOGIN_URL),
HttpWebRequest)
webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy
webRequest.KeepAlive = False
Dim responseReader As StreamReader = New
StreamReader(webRequest.GetResponse.GetResponseStr eam)
Dim responseData As String = responseReader.ReadToEnd
responseReader.Close()

On my production box, I get this error:
The underlying connection was closed. Unable to connect to the remote server.

I have made sure I have .NET framework 1.1 SP 1 installed

I have added the following code to my web.config file

<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxy:port"
bypassonlocal="false"
/>
</defaultProxy>
</system.net>

And now I am at a loss?

Any thoughts?
Thanks

--
Tyler

May 3 '06 #2
Thanks for your response Peter. I tried both suggestions with the same
result. This one has me baffled. I can type the url into a browser on the
production box and it will pull up the site just fine. And again, it works
on my development box, but not the production box.
--
Tyler
"Peter Bromberg [C# MVP]" wrote:
Um,
don't you want GetDefaultProxy, not
webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy

Its' DefaultProxy that you show in your config. You can also try more
specific code like this:

if (ConfigurationSettings.AppSettings["proxy"] != null)
{
WebProxy p = null;
string proxyAddressAndPort =
ConfigurationSettings.AppSettings["proxy"];
string proxyUserName =
ConfigurationSettings.AppSettings["proxyUserName"];
string proxyPassword =
ConfigurationSettings.AppSettings["proxyPassword"];
ICredentials cred;
cred = new NetworkCredential(proxyUserName, proxyPassword);
p = new WebProxy(proxyAddressAndPort, true, null, cred);
GlobalProxySelection.Select = p;
}
Peter
--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"Tyler" wrote:
I am using httpwebrequest to do a screen scrape.

This works great on my development box, but does not on the production box.

Here is the code.

Dim webRequest As HttpWebRequest = CType(webRequest.Create(LOGIN_URL),
HttpWebRequest)
webRequest.Proxy = System.Net.GlobalProxySelection.GetEmptyWebProxy
webRequest.KeepAlive = False
Dim responseReader As StreamReader = New
StreamReader(webRequest.GetResponse.GetResponseStr eam)
Dim responseData As String = responseReader.ReadToEnd
responseReader.Close()

On my production box, I get this error:
The underlying connection was closed. Unable to connect to the remote server.

I have made sure I have .NET framework 1.1 SP 1 installed

I have added the following code to my web.config file

<system.net>
<defaultProxy>
<proxy
usesystemdefault = "false"
proxyaddress="http://proxy:port"
bypassonlocal="false"
/>
</defaultProxy>
</system.net>

And now I am at a loss?

Any thoughts?
Thanks

--
Tyler

May 3 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by Gregory A Greenman | last post: by
1 post views Thread by Jeff B | last post: by
1 post views Thread by Imran Aziz | last post: by
6 posts views Thread by Mike Koerner | last post: by
6 posts views Thread by Oliver | last post: by
2 posts views Thread by =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.