ASP/VBScript Form Post Handling

Discussion in 'ASP General' started by xernoth@googlemail.com, May 31, 2008.

  1. Guest

    Hi there,

    Just a quick question. I'm more familiar with C# and ASP.NET but need
    to use ASP/VBScript for a quick project.

    I have a form that uploads content to a server not managed by us. When
    the form is filled in and posted, the response from the server is an
    XML response. However when that happens, I'm not longer at my asp
    page, I'm redirected the XML response URL that's managed by the third
    party server.

    I have two questions are a result:
    1) I understand I can use XmlHTTP to simulate a form and post that
    using XmlHttp.Send String. However, the form that uploads content is
    quite complex. It contains 4 type=text input fields, 1 textarea field,
    and a type=file field.
    How would I specify all this in the XmlHttp.Send String? More
    specifically, how would I specify the type=file field? When using a
    proxy trace application to manually intercept my post, the type=file
    field looks like this:
    Content-Disposition: form-data; name="file1"; filename="C:
    \mediaexample.wmv"
    Content-Type: video/x-ms-wmv

    2) Is there anyway to specify a html form in the XmlHttp.Send? So
    instead of having to build a string with all the form information,
    just reference the form name and Send that instead?

    Any ideas would be appreciate. For the record, I've done extensive
    browsing, and although I've come across useful information, nothing
    that quite answers my dilemma. If I'm overlooking the obvious, please
    let me know.

    Thanks.
    , May 31, 2008
    #1
    1. Advertising

  2. <> wrote in message
    news:...
    > Hi there,
    >
    > Just a quick question. I'm more familiar with C# and ASP.NET but need
    > to use ASP/VBScript for a quick project.
    >
    > I have a form that uploads content to a server not managed by us. When
    > the form is filled in and posted, the response from the server is an
    > XML response. However when that happens, I'm not longer at my asp
    > page, I'm redirected the XML response URL that's managed by the third
    > party server.
    >
    > I have two questions are a result:
    > 1) I understand I can use XmlHTTP to simulate a form and post that
    > using XmlHttp.Send String. However, the form that uploads content is
    > quite complex. It contains 4 type=text input fields, 1 textarea field,
    > and a type=file field.
    > How would I specify all this in the XmlHttp.Send String? More
    > specifically, how would I specify the type=file field? When using a
    > proxy trace application to manually intercept my post, the type=file
    > field looks like this:
    > Content-Disposition: form-data; name="file1"; filename="C:
    > \mediaexample.wmv"
    > Content-Type: video/x-ms-wmv
    >
    > 2) Is there anyway to specify a html form in the XmlHttp.Send? So
    > instead of having to build a string with all the form information,
    > just reference the form name and Send that instead?
    >
    > Any ideas would be appreciate. For the record, I've done extensive
    > browsing, and although I've come across useful information, nothing
    > that quite answers my dilemma. If I'm overlooking the obvious, please
    > let me know.


    Question 2 first: No.

    Question1 :

    Whilst it is quite possible to emulate a mime mulltipart form post with
    XmlHttp send the problem will be the file data field. The client side code
    will need to be able to read the local file in order to encode its bytes
    into the post. However to do that without some custom component support
    would require the user to reduce IE security to what is likely to be an
    unacceptably weak level.

    One option would be to make the action of the form point at a page on your
    site and have that repeat the post to the third party. There are number of
    downsides such as the extra bandwidth load on your site and extra complexity
    if the third party requires session management.





    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, May 31, 2008
    #2
    1. Advertising

  3. Old Pedant Guest

    > 2) Is there anyway to specify a html form in the XmlHttp.Send? So
    > instead of having to build a string with all the form information,
    > just reference the form name and Send that instead?


    Why not just do
    Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
    http.Open "POST", "...url..."
    http.Send Request.Form
    ???

    That is, just "forward" the entire contens of the form to the remote site??



    >
    > Any ideas would be appreciate. For the record, I've done extensive
    > browsing, and although I've come across useful information, nothing
    > that quite answers my dilemma. If I'm overlooking the obvious, please
    > let me know.
    >
    > Thanks.
    >
    Old Pedant, May 31, 2008
    #3
  4. "Old Pedant" <> wrote in message
    news:...
    > > 2) Is there anyway to specify a html form in the XmlHttp.Send? So
    > > instead of having to build a string with all the form information,
    > > just reference the form name and Send that instead?

    >
    > Why not just do
    > Set http = Server.CreateObject("msxml2.ServerXMLHTTP")
    > http.Open "POST", "...url..."
    > http.Send Request.Form
    > ???
    >
    > That is, just "forward" the entire contens of the form to the remote

    site??
    >
    >



    The won't work in this case because in order to upload a file the form
    encoding needs to be multipart/form-data. The ASP Form object can't read
    that type of form data.

    I was thinking of something more raw than that :-

    Dim xhr : Set xhr = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")

    xhr.Open "POST", "..url..", false
    xhr.setRequestHeader "Content-Type",
    Request.ServerVariables("HTTP_CONTENT_TYPE")
    xhr.send Request.BinaryRead(Request.TotalBytes)

    Now the xhr.ResponseXML can be transformed to respond to the client.


    --
    Anthony Jones - MVP ASP/ASP.NET
    Anthony Jones, Jun 1, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chester
    Replies:
    0
    Views:
    110
    Chester
    Jul 30, 2004
  2. Don Glover the younger

    ASP, FORMS, POST METHOD And Post with out form(???)

    Don Glover the younger, Jul 13, 2003, in forum: ASP General
    Replies:
    0
    Views:
    434
    Don Glover the younger
    Jul 13, 2003
  3. hermand

    ASP/VBScript Form Help

    hermand, Jan 18, 2006, in forum: ASP General
    Replies:
    3
    Views:
    245
  4. J. Muenchbourg
    Replies:
    0
    Views:
    343
    J. Muenchbourg
    Aug 6, 2003
  5. yer darn tootin

    Handling URL timeout on form POST

    yer darn tootin, Nov 14, 2007, in forum: Javascript
    Replies:
    2
    Views:
    95
    yer darn tootin
    Nov 14, 2007
Loading...

Share This Page