receiving post information

G

Guest

Hello

My company has a java based application that can post a log file to a url
and I am trying to develop an ASP.Net web page to receive it and then store
the information in a SQL database. I am not sure how to do this and I have
ran across a couple of samples but they do not seem to work. Here is what I
have so far.

I am trying here to determine what key is being passed in order to pull the
value from it, but the output of the string variable is n/a which is it's
initial value.
Dim x As Object
Dim availableKeys As String = "n/a"

For Each x In Request.Form.Keys
If x.ToString <> Nothing Then
If availableKeys = "n/a" Then
availableKeys = x.ToString
Else
availableKeys = availableKeys & " " & x.ToString
End If
End If
Next

Here I am trying to read the value of what I think the key name is and then
writing it out to a file on the server as well as the availablekeys string
contents.
Dim serverRequest As String = Request.Form.Get("status")

Dim FileContents, FilePath As String
Dim sw As StreamWriter

FileContents = availableKeys & vbCrLf & vbCrLf & serverRequest
FilePath = MapPath("rawurl.txt")
sw = New StreamWriter(FilePath)
sw.Write(FileContents)
sw.Flush()
sw.Close()

when I receive the post the code does write out the availablekeys value
which is n/a but nothing else.

I have this site running on port 80 and the system does write out the files
so it should be a rights issue.

If anyone has any thoughts please responde.
 
B

bruce barker

the java app is probably just posting a file, not doing a form post.

try:


sw = New StreamWriter(FilePath)
byte[] buffer = new byte[1024];
int c;
while ((c = Request.InputStream.Read(
buffer,0,buffer.Length)) > 0)
{
sw.Write(buffer,0,c);
}
sw.Close();

-- bruce (sqlwork.com)
 
G

Guest

Bruce

Thank you for your help with this question. Sadly I took your advise and it
still didn't work. I did a little more digging and the reason I was not
getting the information was because IIS was dropping it. It seems that the
Java app is not sending the length field that is required by IIS in order to
do the file posting.

But I would still like to thank you for posting an answer.

bruce barker said:
the java app is probably just posting a file, not doing a form post.

try:


sw = New StreamWriter(FilePath)
byte[] buffer = new byte[1024];
int c;
while ((c = Request.InputStream.Read(
buffer,0,buffer.Length)) > 0)
{
sw.Write(buffer,0,c);
}
sw.Close();

-- bruce (sqlwork.com)


Hello

My company has a java based application that can post a log file to a url
and I am trying to develop an ASP.Net web page to receive it and then store
the information in a SQL database. I am not sure how to do this and I have
ran across a couple of samples but they do not seem to work. Here is what I
have so far.

I am trying here to determine what key is being passed in order to pull the
value from it, but the output of the string variable is n/a which is it's
initial value.
Dim x As Object
Dim availableKeys As String = "n/a"

For Each x In Request.Form.Keys
If x.ToString <> Nothing Then
If availableKeys = "n/a" Then
availableKeys = x.ToString
Else
availableKeys = availableKeys & " " & x.ToString
End If
End If
Next

Here I am trying to read the value of what I think the key name is and then
writing it out to a file on the server as well as the availablekeys string
contents.
Dim serverRequest As String = Request.Form.Get("status")

Dim FileContents, FilePath As String
Dim sw As StreamWriter

FileContents = availableKeys & vbCrLf & vbCrLf & serverRequest
FilePath = MapPath("rawurl.txt")
sw = New StreamWriter(FilePath)
sw.Write(FileContents)
sw.Flush()
sw.Close()

when I receive the post the code does write out the availablekeys value
which is n/a but nothing else.

I have this site running on port 80 and the system does write out the files
so it should be a rights issue.

If anyone has any thoughts please responde.
 

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

Members online

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top