Issue with System.Net.HttpWebRequest

  • Thread starter Greg Reevosh via .NET 247
  • Start date
G

Greg Reevosh via .NET 247

Hi,

I have an issue with System.Net.HttpWebRequest object. Iamtrying to do call to Java Servlet that does userauthentication and then redirects to requested page and startsrequested process. It looks somethink like this:

http://SOMEHOST:10001/servlet/Servlet?_action=LOGIN&_User=USER
&_Pass=PASS&_fromLoginPage=TRUE&_language=''&_OrigUrlToRedirectTo=HTTP://SomeURL/doSERVLET?method=sta...e[0]=inUserID&varValue[0]=0&_serviceName=NAME

I get this error:

System.Net.WebException: (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResultasyncResult)
at System.Net.HttpWebRequest.GetResponse()

When I put the URL into browser it works fine. Any Ideas?

Thanks
 
F

Feroze [msft]

The 500 error means that there was a server error. The server might be
sending a page with that error. You can read that page to see what is wrong.
See the following code for eg:

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(...);
HttpWebResponse resp = null;
try {
resp = (HttpWebResponse)req.GetResponse();
} catch(WebException e) {
Console.WriteLine(e);
if(e.Status == WebExceptionStatus.ProtocolError)
resp = (HttpWebResponse)e.Response;
} catch(Exception e) {
Console.WriteLine(e);
throw;
}

if(resp != null) {
Stream respstream = resp.GetResponseStream();
// read the response stream & close it after your done. The contents
might give a hint as to what is wrong.
}

--
feroze

-----------------
This posting is provided as-is. It offers no warranties and assigns no
rights.

See http://weblogs.asp.net/feroze_daud for System.Net related posts.
----------------

Hi,

I have an issue with System.Net.HttpWebRequest object. I amtrying to do
call to Java Servlet that does user authentication and then redirects to
requested page and starts requested process. It looks somethink like this:

http://SOMEHOST:10001/servlet/Servlet?_action=LOGIN&_User=USER
&_Pass=PASS&_fromLoginPage=TRUE&_language=''&_OrigUrlToRedirectTo=HTTP://Som
eURL/doSERVLET?method=start%26triggerType=ServiceAsync%26user=USER%26trigger
Name=NAME%26product=PRODUCT%26dataArea=AREA%26workTitle=TITLE%26varName[0]=i
nUserID%26varValue[0]=0&_serviceName=NAME

I get this error:

System.Net.WebException: (500) Internal Server Error.
at System.Net.HttpWebRequest.CheckFinalStatus()
at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
at System.Net.HttpWebRequest.GetResponse()

When I put the URL into browser it works fine. Any Ideas?

Thanks
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top