System.Net.WebException: The remote server returned an error: (500) Internal Server E


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: System.Net.WebException: The remote server returned an error: (500) Internal Server E

  1. #1
    Join Date
    Sep 2007
    Posts
    3

    System.Net.WebException: The remote server returned an error: (500) Internal Server E

    Hi All,

    I am not a .Net developer basically,but I have been given the task to look into why an application built on .NET framework gets an error while trying to access our GUI which has been built on JAVA and STRUTS.

    I was trying to debug the application by putting

    System.Windows.Forms.MessageBox.Show() whereever I suspected the problem to be and then started the server in debug mode. It seems that the below line is the culprit -

    byte[] responseArray =
    mWebClient.UploadValues(URL, "POST", paramList);

    paramList is an instance of NameValueCollection and URL is a valid representation of the URL to the GUI I want to access in String format.


    This is the stack trace of the error I get -

    System.Net.WebException: The remote server returned an error: (500) Internal Server Error.
    at System.Net.WebClient.UploadValues(Uri address,String method,NameValueCollectionData data)
    at System.Net.WebClient.UploadValues(String address,String method,NameValueCollectionData data)
    .
    .
    .

    I did some google on the above errror and the closest thing I got was that for version 1.1 and higher of .NET, the machine.config has the entries for httpPost and httpGet commented by default, but I tried that and still I am unable to resolve my issue.



    Can someone please help me with this issue ??

    Thanks and Regards,
    Aryaan

  2. #2
    Join Date
    Sep 2007
    Posts
    86

    Re: System.Net.WebException: The remote server returned an error: (500) Internal Serv

    The error you are receiving is a rather vague error, unfortunately. This error message tends to be used as a wrapper when something goes wrong internally.

    One of the common causes of an error like you are seeing is that the proper user credentials are not being passed when the connection is established. How are you passing the credentials? Are you passing credentials at all?

    Here is a sample where I am calling the Lists web service within SharePoint and passing the credentials of the current user:

    Code:
    MyListsService.Lists listService = new MySample.MyListsService.Lists();
    
    // Authenticate the current user by passing their default
    listService.Credentials = CredentialCache.DefaultNetworkCredentials;
    
    // Set the Url property of the service for the path to a subsite.
    listService.Url = "http://MyServer/sites/MySample/_vti_bin/lists.asmx"; 
    
    XmlNode node = listService.GetListItems("Technologies", string.Empty, null, null, string.Empty, null, null);

    Hope this helps,

    John Wiese
    ISV Architect Evangelist - MIcrosoft
    http://blogs.msdn.com/usisvde

  3. #3
    Join Date
    Sep 2007
    Posts
    3

    Smile Re: System.Net.WebException: The remote server returned an error: (500) Internal Serv

    Hi John,

    Thanks for the quick reply !!!

    One of the common causes of an error like you are seeing is that the proper user credentials are not being passed when the connection is established. How are you passing the credentials? Are you passing credentials at all?

    No, I cant see any code that passes user credentials. Actually, a little bit more information on the background.

    The Java/Struts application has now been enhanced to use Janus Authentication. Earlier, without this Janus authentication the given code used to work perfect and was able to access the GUI built on Java/Struts without any problems.

    Now, I have 3 basic questions -

    1.) Do we need to pass the user credentials in the code before trying to POST as in UploadValues method().

    2.) Can we do it in some config file like machine.config or web.config instead of the code ?

    3.) Is there some command which can tell me the version of .NET framework I am using as I need to check the version on my system ?? (Something like java -version )


    Please forgive me if I have asked something really stupid or silly .. as this is the first time I am seeing a .NET code and things even simple are not obvious to me at this stage.

    Thanks and Regards,
    Aryan

  4. #4
    Join Date
    Sep 2007
    Posts
    86

    re: System.Net.WebException: The remote server returned an error: (500) Internal Serv

    Aryan,

    Gald to help! Here's what I can tell you:

    1. Yes, you will likely need to pass the credentials. This is likely your problem, as you mention that you are now using an authentication tool. I recommend looking at the following MSDN link to see how you can accomplish this:

    http://msdn2.microsoft.com/en-us/lib...redential.aspx


    2. Yes, you could put the login information into a config file or more appropriate as application level settings (which end up in a config file). Keep in mind that these will be stored in a plain text file that anyone with access to the machine could see. You may want to consider encrypting these, and then decrypting them in your code before using them.


    3. No command that I am aware of, but you can simply check the following directory to see what versions are installed:

    Code:
    C:\Windows\Microsoft.NET\Framework

    You may also want to look at the documentation for the WebClient class as it has some more information that may be useful as well:

    http://msdn2.microsoft.com/en-us/lib...webclient.aspx

    John

  5. #5
    Join Date
    Sep 2007
    Posts
    3

    Re: System.Net.WebException: The remote server returned an error: (500) Internal Serv

    John,

    Thanks a lot for the references. I will surely go through them but just a few things I wanted to let you know.

    1.) Even though we have upgraded our UI based on Java/Struts to use a new Authentication server JANUS, we have seen to it that if the request to access comes from the .NET based application, we dont want to authenticate them. This is being achieved by means of a filter in my web.xml
    And this was the way, it worked before we had this Authentication server also.

    2.) Is there some way, by which I can programmatically allow the httpPost or httpGet methods from my code just before the method UploadValues is called ???


    Thanks and Regards,
    Aryan

Similar Threads

  1. Replies: 3
    Last Post: 06-02-2006, 10:00 PM
  2. Replies: 0
    Last Post: 01-31-2003, 08:59 AM
  3. Projects on a remote server
    By Lyle in forum ASP.NET
    Replies: 0
    Last Post: 12-05-2002, 12:39 AM
  4. Replies: 0
    Last Post: 04-15-2002, 01:46 PM
  5. Replies: 7
    Last Post: 09-15-2000, 09:44 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center