473,756 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(webReques t.Create(LOGIN_ URL),
HttpWebRequest)
webRequest.Prox y = System.Net.Glob alProxySelectio n.GetEmptyWebPr oxy
webRequest.Keep Alive = False
Dim responseReader As StreamReader = New
StreamReader(we bRequest.GetRes ponse.GetRespon seStream)
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
usesystemdefaul t = "false"
proxyaddress="h ttp://proxy:port"
bypassonlocal=" false"
/>
</defaultProxy>
</system.net>

And now I am at a loss?

Any thoughts?
Thanks

--
Tyler
May 3 '06 #1
2 3336
Um,
don't you want GetDefaultProxy , not
webRequest.Prox y = System.Net.Glob alProxySelectio n.GetEmptyWebPr oxy

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

if (ConfigurationS ettings.AppSett ings["proxy"] != null)
{
WebProxy p = null;
string proxyAddressAnd Port =
ConfigurationSe ttings.AppSetti ngs["proxy"];
string proxyUserName =
ConfigurationSe ttings.AppSetti ngs["proxyUserN ame"];
string proxyPassword =
ConfigurationSe ttings.AppSetti ngs["proxyPassw ord"];
ICredentials cred;
cred = new NetworkCredenti al(proxyUserNam e, proxyPassword);
p = new WebProxy(proxyA ddressAndPort, true, null, cred);
GlobalProxySele ction.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(webReques t.Create(LOGIN_ URL),
HttpWebRequest)
webRequest.Prox y = System.Net.Glob alProxySelectio n.GetEmptyWebPr oxy
webRequest.Keep Alive = False
Dim responseReader As StreamReader = New
StreamReader(we bRequest.GetRes ponse.GetRespon seStream)
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
usesystemdefaul t = "false"
proxyaddress="h ttp://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.Prox y = System.Net.Glob alProxySelectio n.GetEmptyWebPr oxy

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

if (ConfigurationS ettings.AppSett ings["proxy"] != null)
{
WebProxy p = null;
string proxyAddressAnd Port =
ConfigurationSe ttings.AppSetti ngs["proxy"];
string proxyUserName =
ConfigurationSe ttings.AppSetti ngs["proxyUserN ame"];
string proxyPassword =
ConfigurationSe ttings.AppSetti ngs["proxyPassw ord"];
ICredentials cred;
cred = new NetworkCredenti al(proxyUserNam e, proxyPassword);
p = new WebProxy(proxyA ddressAndPort, true, null, cred);
GlobalProxySele ction.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(webReques t.Create(LOGIN_ URL),
HttpWebRequest)
webRequest.Prox y = System.Net.Glob alProxySelectio n.GetEmptyWebPr oxy
webRequest.Keep Alive = False
Dim responseReader As StreamReader = New
StreamReader(we bRequest.GetRes ponse.GetRespon seStream)
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
usesystemdefaul t = "false"
proxyaddress="h ttp://proxy:port"
bypassonlocal=" false"
/>
</defaultProxy>
</system.net>

And now I am at a loss?

Any thoughts?
Thanks

--
Tyler

May 3 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
19356
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is able to fill that one out just fine. The second form is multipart/form-data. Unfortunately, I haven't been able to fill that out in a way that makes the server happy. I set up a copy of this form at my web site so that I could see exactly what a...
4
5042
by: Steven Pu | last post by:
Hi, Specifically, the website I am trying to access is, https://gmail.google.com/ I've read elsewhere that Google only uses SSL2, while .NET uses SSL3 and is not backward compatible. Is this true? In any case, I want to know how this problem can be solved. The code
1
12600
by: Jeff B | last post by:
I'm trying to create a simple screen scraping application and I kept getting a System.Net.WebException thrown back with a message of "The operation has timed-out." At first I thought it was some kind of connectivity issue on the machine. It didn't make sense though, because I can open up a browser on the same machine and easily browse the web. I'm stumped. I looked over my code for any errors and just couldn't find what I was doing...
15
515
by: warlord | last post by:
I have a windows client app that is trying to download a file from a web server but I always get the following error when I call the GetResponse method of the Request object. The remote server returned an error: (404) Not Found. When I run it against a website on my local machine everything works perfectly, but not against the remote server. I'm sure it's a security or permissions problem of some sort, but I'm not sure where to start.
2
20178
by: GlennLanier | last post by:
Hello, I've searched the forums and can't find an answer -- if it i there, kindly point me in that direction. I would like to simulate a browser POSTing a FORM and be able to pars the response. I have the following code in my Page_Load (litResponse is defined a <ASP:Literal>):
1
12305
by: Imran Aziz | last post by:
Hello All, I am using HttpWebRequest to fetch webpages in my ASP.net C# application. The request works fine without the proxy, but on using the code from within a network that uses proxy the request does not work. I tried to use the MS code to get around it, but having problems using it. The first thing is that the this conversion myProxy=(WebProxy)myWebRequest.Proxy; does not work, and I get an error of cannot convert...
6
4200
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." Is there a way to make sure that the date header is sent over or a way to work around this exception? Here's a sample of the code:
6
1971
by: Oliver | last post by:
I have a very wired problem requesting one specific url from within my application. I have struggeled with this for 5 hours now, and searched google withour any luck, so i hope that someone are able to help me. Here is the code that i am using: Dim url As String = "MyIP" Dim httpRequest As HttpWebRequest = CType(WebRequest.Create(url),
3
4887
by: matadon | last post by:
Hi, I am writing a C# app. I have a finite (~50) set of URLs that I am continuously polling in a circular manner. I would like to do this in a way that can send out each of the requests and get responses as quickly as possible, then do it again. For my last attempt, I tried implementing a circular queue of precreated HttpWebRequest objects, then creating a HttpWebResponse, StreamReader, and Stream and disposing of them after usage. My...
2
3485
by: =?Utf-8?B?TGFycnlLdXBlcm1hbg==?= | last post by:
Our WebDev team seems to have found a problem that exposes a bug in .NET 2.0. This problem can be shown when trying to access a WebService using SSL and through a proxy server after using the HttpWebRequest object. Under normal circumstances I am able to use the webservice without any problems. But after using an HttpWebRequest object to make a call to a website all subsequent attempts to use the WebService will fail with a 401...
0
9462
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10046
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9886
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9857
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9722
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6542
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5318
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3369
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.