500 error while GetResponse()

G

Guest

Hi All,

I'm trying to make a web request to my site from some other ASP.Net
Application. Code used for that is:

string sURL = "<my site url>";

HttpWebRequest wrGETURL = (HttpWebRequest) WebRequest.Create(new Uri(sURL));

wrGETURL.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0;
..NET CLR 1.1.4322)";

wrGETURL.AllowAutoRedirect = true;
wrGETURL.CookieContainer = new CookieContainer();

wrGETURL.CookieContainer.Add(new Uri(sURL), new Cookie("bhResults",
"bhtz=0"));

wrGETURL.CookieContainer.Add(new Uri(sURL), new Cookie("bhPrevResults",
"bhtz=0"));

HttpWebResponse webresponse = (HttpWebResponse)wrGETURL.GetResponse();

I get an error when GetResponse() is executed. The error is :

"The remote server returned an error: (500) Internal Server Error."

Any ideas why i'm getting this error?

Thnx in advance.
Pooja.
 
J

Juan T. Llibre

Your web request code couldn't have provoked that error
because your WR code did not execute at the other server.

If you received a 500 error from the other server,
it's the other server which has some problem
which needs to be determined and solved.




Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
=============================
 
G

Guest

Hi,

Thnx for a quick response.

Actually as of now both the applications are lying on the same machine i.e.
my local machine. Both are running on the same web server.

Thnx,
Pooja.
 
J

Juan T. Llibre

In that case, turn off "Show friendly error messages" in IE,
so you can get an error message which says something meaningful.

From within IE :
Tools -> Internet Options -> Advanced Tab
-> Uncheck "Show Friendly Error Messages".

You might also need to set debug=true in web.config,
if you intend to debug your offending application :


<configuration>
<compilation debug="true"/>
</configuration>

Do those two things to start out, and let us know what happens.




Juan T. Llibre
ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
=============================
 
G

Guest

Hi,

I tried doing both the things but no luck. Its still giving me the same error.

In my web application i already have debug=true. But can i actually go and
debug the web application thru this console app?

Thanks,
Pooja.
 
K

Kevin Spencer

HttpWebResponse webresponse = (HttpWebResponse)wrGETURL.GetResponse();
I get an error when GetResponse() is executed. The error is :

"The remote server returned an error: (500) Internal Server Error."

This question is a bit confusing. It sounds like you're saying that the line
that executes the GetResponse method is throwing an error. However, you say
that the error is "The remote server returned an error: (500) Internal
Server Error." Now, as you're developing an ASP.Net application, this could
mean one of 2 things:

1. The Response contains a 500 status code.
2. Your ASP.Net Page is displaying a 500 status code.

The first would mean that the server that your WebRequest sent a Request to
has a problem.
The second would mean that your ASP.Net app has a problem.

If your app is not the one having a problem, where are you seeing this
error? An HttpWebResponse will contain the status code and other information
about the success or failure of the Request. But if the problem is in your
app, you need to be more specific about how you're getting this error
information.

Can you clear this issue up?

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Hi Kevin,

I'll try to explain it again:

I have developed an ASP.Net application - www.ABC.com

Now i want to develop a utility which checks whether my site is up or not.
If it is not then i need to send an SMS alert to few people to check the
status of the site.

This utility is a console app which makes a HTTPRequest to - www.ABC.com
So, the point at which i say - GetResponse() - i.e. when i'm trying to get
the response of the request i made to my site, its giving me a
System.WebException - "The remote server returned an error: (500) Internal
Server Error."

Hope i'm able to explain the problem in a better way this time.

Thanks,
Pooja.
 
M

michaelcoleman72

This means your web-app is not responding. Check the eventlog (on the
web server) for errors. The page your hitting may require some input
that your test pinger is not supplying. Perhaps run the pinger against
your local web-app in VS.

Regards
Coleman
 
M

michaelcoleman72

Just looked at your test code again. I bet you're having a problem
with a value stored in the cookie. Test in your dev environment.

Regards
Coleman
 
K

Kevin Spencer

Thanks Pooja,

You should be able to get more information about the error from the
WebException thrown. Here's a handy function I wrote to get the details:

public static string GetWebException(WebException ex)
{
try
{
StringBuilder sb = new
StringBuilder(ex.Response.ResponseUri.ToString());
sb.Append(Environment.NewLine + "Status: " + ex.Status.ToString());
sb.Append(Environment.NewLine + "Message: " + ex.Message);
if (ex.InnerException != null)
{
sb.Append(Environment.NewLine +
ex.InnerException.GetType().ToString());
sb.Append(Environment.NewLine +
ex.InnerException.Message);
}
return sb.ToString();
}
catch (Exception e)
{
Utilities.HandleError(e, false, "Error Getting WebException: " +
Environment.NewLine + ex.Message);
return "Error Getting WebException";
}
}

You would of course need to handle any Exception thrown by this method with
your own exception handler, rather than the one I used, which is one I
wrote. The one I wrote logs the Exception message to the Event Log, and
optionally rethrows it, as well as adding any string you want to append to
it.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.
 
G

Guest

Hi,

I included the code provided by u, and it gave me this error:

http://www.9wagents.com/JetTravelPortal/SorryPage.aspx?aspxerrorpath=/JetTravelPortal/Default.aspx
Status: ProtocolError
Message: The remote server returned an error: (500) Internal Server Error.

Also, in the Event Viewer it displayed the following error:

---------------------------------------------------------------------
Event Type: Error
Event Source: SQLSERVERAGENT
Event Category: Alert Engine
Event ID: 318
Date: 9/8/2005
Time: 9:23:47 AM
User: N/A
Computer: MJIE-0059
Description:
Unable to read local eventlog (reason: The event log file has changed
between read operations).

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.
---------------------------------------------------------------------

What can i do next to get closer to the error?

Thanks,
Pooja.
 
J

Joerg Jooss

Pooja said:
Hi,

I included the code provided by u, and it gave me this error:

http://www.9wagents.com/JetTravelPortal/SorryPage.aspx?aspxerrorpath=/
JetTravelPortal/Default.aspx Status: ProtocolError
Message: The remote server returned an error: (500) Internal Server
Error.

Also, in the Event Viewer it displayed the following error:

---------------------------------------------------------------------
Event Type: Error
Event Source: SQLSERVERAGENT
Event Category: Alert Engine
Event ID: 318
Date: 9/8/2005
Time: 9:23:47 AM
User: N/A
Computer: MJIE-0059
Description:
Unable to read local eventlog (reason: The event log file has changed
between read operations).

For more information, see Help and Support Center at
http://go.microsoft.com/fwlink/events.asp.

Why don't you simply debug your ASP.NET application? It's clearly a
server-side error.

Cheers,
 

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,769
Messages
2,569,582
Members
45,062
Latest member
OrderKetozenseACV

Latest Threads

Top