HTTP Handlers

Discussion in 'ASP .Net Web Controls' started by Ertan Sekmen, Nov 3, 2003.

  1. Ertan Sekmen

    Ertan Sekmen Guest

    hi there,
    I do not know if this is the correct form to post this but I would kindly
    ask any help on creating a class to submit a Form.

    We have a webservice that accepts web forms. when we create a form with a
    textarea called data, (the value is an XMLDocument) then submit this form
    via action=https://blabla... it works fine. But I would like to implement
    this operation in our business layer, which is a class.

    I started with creating httpwebrequest object. but "result" string is always
    empty. I try this another web page, it works great.

    I think that the blabla server process only web forms, something like
    request.form("data"). How can I add form values to httprequest? I search
    through msdn and I Found that there are two objects : System.Web.HttpRequest
    and System.Net.HttpWebRequest. I cannot get System.Web.HttpRequest object
    working. when I try to add a value & key pair to
    System.Web.HttpRequest.forms collection it raises an error : "forms
    collection is read only".

    Thanks in advance,
    Ertan



    '-- code begins here
    Dim oRequest As HttpWebRequest = WebRequest.Create("https://blabla")

    Dim myWriter As StreamWriter
    Dim encoding As New ASCIIEncoding
    Dim postData As String


    Dim result As String
    Dim xmlFile As String = New StreamReader("c:\xmldoc.xml").ReadToEnd
    postData = "DATA=" & xmlFile
    Dim data As Byte() = encoding.GetBytes(postData)
    oRequest.Form.Set("DATA", postData)
    oRequest.Method = "POST"
    oRequest.ContentLength = data.Length
    oRequest.ContentType = "application/x-www-form-urlencodedl"
    oRequest.KeepAlive = True
    Dim newStream As Stream = oRequest.GetRequestStream()
    Try
    newStream.Write(Data, 0, Data.Length)
    Catch ex As Exception
    Response.Write(ex.Message)
    Finally
    newStream.Close()
    End Try


    Dim oResponse As HttpWebResponse = oRequest.GetResponse()
    Dim sr As StreamReader = New
    StreamReader(oResponse.GetResponseStream())
    result = sr.ReadToEnd
    sr.Close()
    Response.Write(result)
    '--
     
    Ertan Sekmen, Nov 3, 2003
    #1
    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. Chris Hughes
    Replies:
    5
    Views:
    683
    Chris Hughes
    Aug 21, 2003
  2. PCC
    Replies:
    3
    Views:
    1,168
  3. =?Utf-8?B?Qw==?=

    HTTP Handlers

    =?Utf-8?B?Qw==?=, Jun 10, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    453
    John Saunders
    Jun 10, 2004
  4. Norton
    Replies:
    2
    Views:
    684
    Scott Allen
    Aug 23, 2004
  5. msnews.microsoft.com

    HTTP handlers WEB.CONFIG syntax, please !

    msnews.microsoft.com, Feb 2, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    2,460
    msnews.microsoft.com
    Feb 2, 2005
Loading...

Share This Page