473,399 Members | 4,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Internal Server Error, WebRequest.GetResponse

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.WebException' 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.morningstar.com/fundnet/PrintReport.aspx?intCountThisReadry=USA&Symbol=GAT EX"
Dim myRequest As WebRequest = WebRequest.Create(strURL)
Dim myResponse As WebResponse = myRequest.GetResponse()

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 4670
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(WebRequest.Create(strURL),
HttpWebRequest)
myRequest.CookieContainer = New CookieContainer()
myRequest.CookieContainer.SetCookies(myRequest.Req uestUri,
"fp=020114125810442111")
myRequest.ContentType =
"text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5"
myRequest.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US;
rv:1.8.1) Gecko/20061010 Firefox/2.0"
myRequest.Headers.Add(HttpRequestHeader.AcceptLang uage,
"en-us,en;q=0.5")
myRequest.Headers.Add(HttpRequestHeader.AcceptEnco ding, "gzip,
deflate")
myRequest.Headers.Add(HttpRequestHeader.AcceptChar set,
"ISO-8859-1,utf-8;q=0.7,*;q=0.7")
myRequest.Headers.Add(HttpRequestHeader.Pragma, "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.aspx?Symbol=AABPX HTTP/1.1
Content-Type:
text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/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.morningstar.com
Cookie: fp=020114125810442111
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,image/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.morningstar.com
Cookie: fp=020114125810442111

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******@columbus.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.WebException' 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.morningstar.com/fundnet/PrintReport.aspx?intCountThisReadry=USA&Symbol=GAT EX"
Dim myRequest As WebRequest = WebRequest.Create(strURL)
Dim myResponse As WebResponse = myRequest.GetResponse()

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
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 =...
0
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...
0
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...
1
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...
4
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...
0
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)...
1
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...
4
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 =...
3
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 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.