Retrieving values from a post

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bertkuiken
    New Member
    • Oct 2006
    • 1

    Retrieving values from a post

    I'm new to .net and c# but have done this before at j2ee and php.

    All i want is to post a xml file as a string from an external website and retrieve it from the postdata at my c# programming code. Most of the examples online describe the posting of data at an external website, without the code for the external website or examples where the data was posted from an asp page to an asp page.

    This is the code I used, but reading out of the postdata indicates that it's empty.



    <html>
    <head>
    </head>
    <body>

    <form action="Default .aspx" method="post">
    <textarea rows="48" cols="150" id="xml">
    <xml>
    <iets>
    ja
    </iets>
    </xml>
    </textarea><br/>
    <input type="hidden" value="test">
    <input type="submit" value="Post">
    </form>
    </body>
    </html>





    Stream str;
    String strmContents;
    Int32 counter, strLen, strRead;
    // Create a Stream object.
    str = Request.InputSt ream;
    Response.Write( str);
    // Find number of bytes in stream.
    strLen = Convert.ToInt32 (str.Length);
    Response.Write( strLen);
    // Create a byte array.
    byte[] strArr = new byte[strLen];
    // Read stream into byte array.
    strRead = str.Read(strArr , 0, strLen);

    // Convert byte array to a text string.
    strmContents = "";
    for (counter = 0; counter < strLen; counter++)
    {
    strmContents = strmContents + strArr[counter].ToString();
    Response.Write( " a "+counter);
    }
    Response.Write( strmContents);

    StreamReader sr = new StreamReader(Re quest.InputStre am, System.Text.Enc oding.ASCII);
    //Convert the stream to a string
    string s = sr.ReadToEnd();
    sr.Close();
    Response.Write( s);


    There are some extra outputstrings to give more information, but it doesn't tell me much.

    I hope someone can help me get this to work, I tried a lot in the Page_Load function, or am i missing the point and is there a post event function just like j2ee?
Working...