problem with url on http post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CindyH

    problem with url on http post

    Hi:

    I have the following code:

    Dim url As String = "http://xx01xx01:800/some.ashx"
    Dim myrequest As System.Net.WebR equest = Nothing
    Dim myresponse As System.Net.WebR esponse = Nothing
    'Prepare web request
    myrequest = System.Net.WebR equest.Create(u rl)
    'use POST
    myrequest.Metho d = "POST"
    'Set the content type
    Request.Content Type = "applicatio n/x-www-form-urlencoded"
    Dim byteArray As Byte() =
    System.Text.Enc oding.UTF8.GetB ytes(dataToPost )
    'Get length of content
    myrequest.Conte ntLength = byteArray.Lengt h
    'Get request stream
    Dim newStream As System.IO.Strea m = myrequest.GetRe questStream
    'Send the data.
    newStream.Write (byteArray, 0, byteArray.Lengt h)
    ' Close stream
    newStream.Close ()
    'Send the Post request and wait for the response.
    myresponse = myrequest.GetRe sponse()

    If I use for the first line something like this:
    Dim url As String = "http://www.someplace.c om/somepage.aspx" then
    everything works fine, but now I need to use the real address which is
    something like this: "http://xx01xx01:800/some.ashx"
    When the code hits the line:
    Dim newStream As System.IO.Strea m = myrequest.GetRe questStream - I'm
    getting the following error:
    system.net.webe xception: The remote name could not be resolved: 'xx01xx01'
    Does anyone have any ideas why I'm having problems with the stream for a url
    address like this?
    Thanks,
    Cindy


  • Martin Honnen

    #2
    Re: problem with url on http post

    CindyH wrote:
    Dim url As String = "http://www.someplace.c om/somepage.aspx" then
    everything works fine, but now I need to use the real address which is
    something like this: "http://xx01xx01:800/some.ashx"
    When the code hits the line:
    Dim newStream As System.IO.Strea m = myrequest.GetRe questStream - I'm
    getting the following error:
    system.net.webe xception: The remote name could not be resolved: 'xx01xx01'
    Does anyone have any ideas why I'm having problems with the stream for a url
    address like this?
    Is other software on your system able to resolve the host name xx01xx01?
    The host name needs to be resolved into a numerical IP address and that
    fails for 'xx01xx01'. This is a network configuration problem and not an
    XML problem.



    --

    Martin Honnen --- MVP XML

    Comment

    • CindyH

      #3
      Re: problem with url on http post

      The guy gave me the wrong url address.
      Now I'm able to send the post, but response is empty and getting this error:
      system.net.webe xception: The remote server returned an error: (500) Internal
      Server Error.
      Would this be my problem or his?
      Thanks,
      Cindy



      "Martin Honnen" <mahotrash@yaho o.dewrote in message
      news:%23RT%23bX cuIHA.5096@TK2M SFTNGP02.phx.gb l...
      CindyH wrote:
      >
      > Dim url As String = "http://www.someplace.c om/somepage.aspx" then
      >everything works fine, but now I need to use the real address which is
      >something like this: "http://xx01xx01:800/some.ashx"
      >When the code hits the line:
      > Dim newStream As System.IO.Strea m = myrequest.GetRe questStream - I'm
      >getting the following error:
      >system.net.web exception: The remote name could not be resolved:
      >'xx01xx01'
      >Does anyone have any ideas why I'm having problems with the stream for a
      >url address like this?
      >
      Is other software on your system able to resolve the host name xx01xx01?
      The host name needs to be resolved into a numerical IP address and that
      fails for 'xx01xx01'. This is a network configuration problem and not an
      XML problem.
      >
      >
      >
      --
      >
      Martin Honnen --- MVP XML
      http://JavaScript.FAQTs.com/

      Comment

      Working...