"The remote server returned an error: (500) Internal Server Error" error in an intranet website RRS feed

  • Question

  • Hi all,

    I got the following error "The remote server returned an error: (500) Internal Server Error" when i attempt to do a HttpWebRequest on an intranet website of a customer. The intranet needs credential in order to access it. Initially we would have a 401 error but it was because the credentials were not set. Now credentials are set correctly with login/password according to Debug too. But there is an error 500.


    Basically the error happened when doing myResp = (HttpWebResponse)myReq.GetResponse(); in the following code :


    public static string[] UrlExtensionFileSupported(string locationUrl)<br/>
    	string[] saveAsType = null;<br/>
          HttpWebResponse myResp = null;<br/>
    		HttpWebRequest wReq = (HttpWebRequest)WebRequest.Create(locationUrl);<br/>
            wReq.Credentials = new NetworkCredential(LoginCredential.ToString(),<br/>
            myReq.Timeout = 3000;<br/>
            myResp = (HttpWebResponse)myReq.GetResponse();<br/>
            string rawContentType = myResp.ContentType;<br/>
            Utilities.writeToLogFile("INFO : rawContentType=" + rawContentType);<br/>
            saveAsType = getExtensionTypeAndMessage(rawContentType, locationUrl);<br/>
          catch (WebException exception)<br/>
            Utilities.writeToLogFile("ERROR : UrlExtensionFileSupported Exception = " + exception.Message);<br/>
    return saveAsType;<br/>

    How can I fix this error for my customer ?



    Wednesday, October 20, 2010 2:44 PM


  • Hi,

    Can your webpage browsered in your IE browser?

    This could be a server side problem, so you might need to debug your website to see the exactly error detail.

    You can also get the error response from the exception....

    } catch(Exception e) { 
       if (e is WebException && ((WebException)e).Status==WebExceptionStatus.ResponseError) 
          WebResponse errResp = ((WebException)e).Response; 
          using(Stream respStream = errResp.GetResponseStream()) 
             // read the error response 

    Or fiddler is a great tool to debug your server and client httprequest/httpResponse.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    • Marked as answer by Bin-ze Zhao Wednesday, October 27, 2010 3:45 AM
    Monday, October 25, 2010 9:45 AM