Processing simple post data, not form data

E

eselk2003

I have a Windows application that uses the Windows Internet (wininet)
API to post a few lines of text to an ASP.NET page that I'm writing.
I know how to process form data in ASP.NET, but not sure how to
process simple lines of text. I'm a C++ Win32 programmer and have
lots to learn about .NET, and VB.NET.

I imagine I need to use Request.BinaryRead, or Request.InputStream,
and I'm sure I could figure out some way to kludge something together
that looks a lot like what I would do in native C++... but I'm sure I
really only need to write a few lines of code and that those few lines
would work much better.

The post data is just several strings, seperated by line-feeds (vbCrLf
OR \r\n), like this:

hello
test
whatever
thanks

I just want to loop through those lines and add each one to my
database. I know how to handle the database part.

I'm guessing I can probably convert/cast Request.InputStream to some
string reader class already designed for reading one line at a time?
 
B

bruce barker

using (var sr = new StreamReader(Request.InputStream))
{
while (!sr.EndOfStream)
{
Response.Write(sr.ReadLine() + "<br/>");
}
}


-- bruce (sqlwork.com)
 
E

eselk2003

I'm guessing I can probably convert/cast Request.InputStream to some
      using (var sr = new StreamReader(Request.InputStream))
      {
         while (!sr.EndOfStream)
         {
            Response.Write(sr.ReadLine() + "<br/>");
         }
      }

-- bruce (sqlwork.com)

Thank you, exactly what I was looking for.
 

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

Top