473,695 Members | 2,777 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Internal Server Error, WebRequest.GetR esponse

I have a VB.NET 2005 Windows application that worked fine when I ran it
a month ago, and now it is throwing an exception ("The remote server
returned an error: (500) Internal Server Error.") and I don't know why.

The application screen scrapes a web page. If I paste the URL in my
browser's address bar and the expected page comes up just fine.

When I went through the hassle of getting the real response from within
the exception object, it is just the standard ASP.NET error page:

"A first chance exception of type 'System.Net.Web Exception' occurred in
System.dll
Server Error in '/Fundnet' Application.
Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons). It
could, however, be viewed by browsers running on the local server
machine. "

My code is quite simple, and the exception is thrown by the last of
these 3 lines:
Dim strURL As String =
"http://quicktake.morni ngstar.com/fundnet/PrintReport.asp x?intCountThisR eadry=USA&Symbo l=GATEX"
Dim myRequest As WebRequest = WebRequest.Crea te(strURL)
Dim myResponse As WebResponse = myRequest.GetRe sponse()

Does anyone have any idea what could cause this?

(The only thing I can think of that I've changed on my end recently is
that I installed FireFox 2.0 and made it my default browser.
Hopefully, that is irrelevant but I mention it just in case.)

I thoroughly searched Google and Google Groups before posting this and
have been unable to find a relevant article. Thanks for any guidance
you can provide.

- Mark Freeman

Nov 15 '06 #1
1 4708
I used a monitor to see the actual HTTP traffic and found that there
were other headers being sent by the browser when requesting the URL,
so I added those items to the header in my .NET code, and now I can get
the page to load correctly -- sometimes.

Dim myRequest As HttpWebRequest = CType(WebReques t.Create(strURL ),
HttpWebRequest)
myRequest.Cooki eContainer = New CookieContainer ()
myRequest.Cooki eContainer.SetC ookies(myReques t.RequestUri,
"fp=02011412581 0442111")
myRequest.Conte ntType =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5"
myRequest.UserA gent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1) Gecko/20061010 Firefox/2.0"
myRequest.Heade rs.Add(HttpRequ estHeader.Accep tLanguage,
"en-us,en;q=0.5")
myRequest.Heade rs.Add(HttpRequ estHeader.Accep tEncoding, "gzip,
deflate")
myRequest.Heade rs.Add(HttpRequ estHeader.Accep tCharset,
"ISO-8859-1,utf-8;q=0.7,*;q=0.7 ")
myRequest.Heade rs.Add(HttpRequ estHeader.Pragm a, "nocache")

I do this in a loop, using a different parameter in the URL (after the
question mark at the end). Intermittently, it fails with the 500
error. I looked at the monitor again and found something strange.

On some attempts, the request goes out on the wire like this (and
succeeds):

GET /fundnet/PrintReport.asp x?Symbol=AABPX HTTP/1.1
Content-Type:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)
Gecko/20061010 Firefox/2.0
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Pragma: nocache
Host: quicktake.morni ngstar.com
Cookie: fp=020114125810 442111
Proxy-Connection: Keep-Alive

On other attempts, the request looks like this (and gets the
exception):

GET
http://quicktake.morningstar.com/fun...x?Symbol=AABPX
HTTP/1.1
Content-Type:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,ima ge/png,*/*;q=0.5
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1)
Gecko/20061010 Firefox/2.0
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Pragma: nocache
Host: quicktake.morni ngstar.com
Cookie: fp=020114125810 442111

Note that the one that fails has the full URL in the GET (absolute),
whereas the one that succeeds does not include the "http://" prefix or
the server in the GET (relative). Also, the successful one has
"Proxy-Connection: Keep-Alive" and the one that fails does not. I am
not doing anything differently between calls, so it appears to be
something weird within .NET.

Does anyone have any ideas?

- Mark

mf******@columb us.rr.com wrote:
I have a VB.NET 2005 Windows application that worked fine when I ran it
a month ago, and now it is throwing an exception ("The remote server
returned an error: (500) Internal Server Error.") and I don't know why.

The application screen scrapes a web page. If I paste the URL in my
browser's address bar and the expected page comes up just fine.

When I went through the hassle of getting the real response from within
the exception object, it is just the standard ASP.NET error page:

"A first chance exception of type 'System.Net.Web Exception' occurred in
System.dll
Server Error in '/Fundnet' Application.
Runtime Error
Description: An application error occurred on the server. The current
custom error settings for this application prevent the details of the
application error from being viewed remotely (for security reasons). It
could, however, be viewed by browsers running on the local server
machine. "

My code is quite simple, and the exception is thrown by the last of
these 3 lines:
Dim strURL As String =
"http://quicktake.morni ngstar.com/fundnet/PrintReport.asp x?intCountThisR eadry=USA&Symbo l=GATEX"
Dim myRequest As WebRequest = WebRequest.Crea te(strURL)
Dim myResponse As WebResponse = myRequest.GetRe sponse()

Does anyone have any idea what could cause this?

(The only thing I can think of that I've changed on my end recently is
that I installed FireFox 2.0 and made it my default browser.
Hopefully, that is irrelevant but I mention it just in case.)

I thoroughly searched Google and Google Groups before posting this and
have been unable to find a relevant article. Thanks for any guidance
you can provide.

- Mark Freeman
Dec 4 '06 #2

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

Similar topics

0
1402
by: Bp | last post by:
I'm writing a simple HTTPRequest that retrieves the content of a web page. Dim httpReq As System.Net.HttpWebRequest Dim httpResp As System.Net.HttpWebResponse httpReq = CType(System.Net.WebRequest.Create(URLString), System.Net.HttpWebRequest) httpResp = CType(httpReq.GetResponse(), System.Net.HttpWebResponse) The problem is that on certain pages, I get a WebException of "The remote
0
1754
by: Marcus | last post by:
Hi all, I have some code that downloads an XML tree from a web server. If there is a problem returning the requested XML tree from the server, it returns an XML tree with the error message in a 500 internal server error response. I want to get this error message, but WebRequest.GetResponse() throws an error because of the server error, so I can't get a reference to the response. Is there a way around this? Code follows below.
0
2758
by: Johann Blake | last post by:
In my need to decode a JPEG 2000 file, I discovered like many that there was no functionality for this in the .NET Framework. Instead of forking out a pile of cash to do this, I came up with the idea that costs nothing and it is inheritently built into the Framework. So here is the solution... When you use the WebRequest and WebResponse classes to obtain graphics from a web site, these classes have built-in decoding for JPEG 2000 files....
1
3219
by: William F. Robertson, Jr. | last post by:
I am having problems with using the WebRequest object (or HttpWebRequest ). I have created the WebRequest and set the credentials, but when I call GetResponse() it is throwing an internal server error 500 on me. I am running a console app on my sql server that is trying to create a WebRequest to my Webserver to notify the cache on the webserver to refresh itself. The website is using NT authentication. The user I am using is in the...
4
7228
by: Terry | last post by:
Hello, I am trying to get a response for an .aspx page in my current project (same virtual directory) by using WebRequest.GetResponse but I keep getting a exception with "500 Internal server error" in the exception message. I am able to do this fine with another .aspx page that has no code-behind. The page that has code-behind throws the exception. What I am doing is getting the .aspx response, reading the stream, replacing
0
297
by: pintu | last post by:
Hi..I posted my message earlier but it was not properly described..so am posting again. I am working in an application in which i hav to send the contents of an xml file(from my local machine) to another server(www.ups.com) as http-request.As response i will get another xml file from that server. So what i did is i had 1.collected the data by using webrequest and webresponse class's methods (like webreq.create,webreq.getresponse and...
1
8199
by: Tito Meinrath | last post by:
Hi, I'm really going mad about this! Currently I'm designing a student course on web services. Because I want them to understand what's really going on when web services correspond with each other (or other consumers) via SOAP, I want to generate SOAP-messages in XML manually and send it via POST-method to the hosting server. But whenever I try to use HttpWebRequest-Class to get a response from a webservice, I get an "Internal Server...
4
4883
by: Barnali85 | last post by:
Hi all, I am getting "The remote server returned an error: (500) Internal Server Error" exception. I have written the following code in VS.NET2005 using C# : WebRequest wr = WebRequest.Create("http://www.ebizautos.com/search-cars/acura-cl-2.2-1997.html"); WebResponse wrs = wr.GetResponse(); Stream strm = wrs.GetResponseStream(); StreamReader SR = new StreamReader(strm); ...
3
5476
by: =?Utf-8?B?UmljaGFyZEBub3NwYW0ubm9zcGFt?= | last post by:
My webcam app runs OK on XP but not on Vista. Here's my code snippet that has been working up until now: System.Net.WebRequest request; System.Net.WebResponse response; request = System.Net.FileWebRequest.Create( "http://store.bearvalley.com/live/camimage_00001.jpg"); response = request.GetResponse(); When it tries to execute the request.GetResponse() call I get the following
0
8984
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
8847
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
8825
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
7661
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5839
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
4340
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...
1
3003
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2272
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.