500 Internal Server Error



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

Below is the code that I wrote.

Dim xmlDOM As New XmlDocument


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),

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)
Dim myResponse As HttpWebResponse
myResponse = CType(myRequest.GetResponse(), HttpWebResponse)

Dim sr As StreamReader = New StreamReader (myResponse.GetResponseStream())
Dim response As String = sr.ReadToEnd()

Ward Bekker

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"

"Free .Net 2.0 C# to/from VB.Net Code Converter"


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?

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