Sending form headers to ASP.NET from HTTPWebRequest

J

joshuajnoble

[apologies for cross-posting this from the Dot.NET development group,
not sure which is more approriate]

Hi all, I'm having a strange problem where I need to build out form
variables in an HTTPWebRequest and send them to an aspx page for
processing. The page isn't recognizing the form variables at all, and
the only thing I can attribute it to is that when the call works, the
aspx page doesn't send a HTTP/1.1, Status Code = 100 response, i.e.
the calls go like this:

29 1109.853516 192.168.1.108 206.71.164.82 HTTP HTTP: Request, POST /
{serv}/CustomerFile.aspx
30 1109.853516 192.168.1.108 206.71.164.82 HTTP HTTP: HTTP Payload


where the form variables are contained within the initial Request
object:

Body: ------------Ij5gL6ae0Ij5ei4gL6KM7ae0gL6Ij5
Body: Content-Disposition: form-data; name="projectId"
Body:
Body: 159
Body: ------------Ij5gL6ae0Ij5ei4gL6KM7ae0gL6Ij5
Body: Content-Disposition: form-data; name="sessionId"
Body:
Body: wq3zlprijum1q455wwv53kq2

This is done through a Test aspx page that was made just to make sure
that the server was working. The problem is that I need to send a file
to the same aspx page from a desktop app, which means I have to build
out the HTTPWebRequest myself. That I can do fine, but the server
always responds to the initial request:

257 24.547852 JNOBLE srv.com HTTP HTTP: Request, POST /
{serv}/CustomerFile.aspx
258 24.638672 srv.com JNOBLE HTTP HTTP: Response, HTTP/1.1, Status
Code = 100
259 24.639649 JNOBLE srv.com HTTP HTTP: HTTP Payload


and the form variables are always sent in the second payload, in this
case the frame marked 259. The response from the server is always:
"projectId = 0 is unknown", which means that the server isn't getting
those form variables from the inital request, and hence is simply
ignoring them. Anyone know how I can append the form variables to the
initial request, instead of writing it later in the request stream?
I'm thinking that might be the problem but I could be wrong? Any info
or ideas would be greatly appreciated. Thanks so much,

Josh
 
P

Peter Bromberg [C# MVP]

I am not completely clear on exactly what you want to accomplish here, but
you might want to take a look at the simplified WebClient class which
supports an UploadValues method accepting a NameValueCollection of form items.
Or you can use the FileUpload control, which would add it's file to the
posted form collection on a POST.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
 

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