500 Internal Server Error

Discussion in 'ASP .Net' started by Guest, Mar 1, 2006.

  1. Guest

    Guest Guest

    I get the following error when I send a HTTPWebRequest.

    System.Net.WebException: The remote server returned an error: (500) Internal
    Server Error. at System.Net.HttpWebRequest.CheckFinalStatus() at
    System.Net.HttpWebRequest.GetResponse()

    Below is the code that I wrote.
    -------------------------------------

    Dim xmlDOM As New XmlDocument

    xmlDOM.Load("C:/Subs_Req.xml")

    Dim strxml As String = xmlDOM.OuterXml
    Dim myxml As String = "xml=" & strxml
    Dim data() As Byte = System.Text.Encoding.UTF8.GetBytes(myxml.ToString())
    Dim xml As String = System.Web.HttpUtility.UrlEncode(myxml)
    Dim myURL As String= "https://xxxxxx.com:443/xxxx".ToString
    Dim myRequest As HttpWebRequest = CType(WebRequest.Create(myURL),
    HttpWebRequest)

    myRequest.Method = "POST"
    myRequest.ContentType = "application/x-www-form-urlencoded"
    myRequest.ContentLength = data.Length
    Dim NewStream As Stream = myRequest.GetRequestStream()

    NewStream.Write(data, 0, data.Length)
    NewStream.Close()
    Dim myResponse As HttpWebResponse
    myResponse = CType(myRequest.GetResponse(), HttpWebResponse)

    Dim sr As StreamReader = New StreamReader (myResponse.GetResponseStream())
    Dim response As String = sr.ReadToEnd()
     
    Guest, Mar 1, 2006
    #1
    1. Advertisements

  2. Guest

    Ward Bekker Guest

    Hi Beginner,

    It seems that the post to the page on the remote server caused a 500
    Server Error, meaning that an exception occured. Re-check if you are
    posting the correct data, otherwise the receiving page is not programmed
    correctly and needs to be corrected.

    --
    Ward Bekker
    "Asp.Net Discussions for the Professional Developer"
    http://www.dotnettaxi.com

    "Free .Net 2.0 C# to/from VB.Net Code Converter"
    http://www.dotnettaxi.com/Tools/Converter.aspx
     
    Ward Bekker, Mar 1, 2006
    #2
    1. Advertisements

  3. Guest

    Guest Guest

    Thanks for the response.

    When I post the same information to a local server it just works fine. But
    not to this. Mine is a simple asp.net app. The receiving page is also fine.
    Do you think the external url being https could cause this problem?
     
    Guest, Mar 1, 2006
    #3
  4. Guest

    Ward Bekker Guest

    Hi Beginner,

    A starting point might be to investigate what the actual exception is
    that caused the 500 internal server error. If it's a asp.net app you can
    specify in the web.config to show the exact exception to remote hosts.

    --
    Ward Bekker
    "Asp.Net Discussions for the Professional Developer"
    http://www.dotnettaxi.com

    "Free .Net 2.0 C# to/from VB.Net Code Converter"
    http://www.dotnettaxi.com/Tools/Converter.aspx
     
    Ward Bekker, Mar 1, 2006
    #4
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.