I need to take the submitted form fields and manually create an httpwebrequest post (not get) to send to a non asp web service and I have been looking for ages not to try and find out how to do it without sucess. If anyone knows the right way of going about it, I'd be really grateful to see the link! the confusing part for me is that the request contains multiple parameters of different sorts...
For example, I will be using a fileupload control to pick an image to be sent, have a textbox and I'll also need to establish the type of the file uploaded and determine its length, so when I come to do the post, I will be sending the picture name (extrapolated from uploaded file), Description (from text box), a file size (extrapolated from uploaded file) and the actual file itself (usually jpg, but could be gif or png).
I must be totally daft, but I can't see how to set multiple parameters on the post request...
Use the HTTPWebRequest object to send POSTS programmatically with your code. I believe you can just create a string of value pairs like:
Dim strPost as string = "parameter1=value¶meter2=value¶meter3=value"
Then post that string to the app using the HTTPWebRequest.
If you've never done this before, you'll want to research the HTTPWebRequest object. Its a bit of a beast to get working.
Thanks, but "Dim strPost as string = parameter1=value¶meter2=value¶meter3=value"
is "get" stuff for querystring, that I don't want to do! I can't post a 800kb image in the querystring!
Hi carled,
The examples in the following Url use POST method with HTTPwebRequest. It reads data using Console.ReadLine() method, you can replace it to make it read stream from a file.
http://msdn2.microsoft.com/en-us/library/system.net.httpwebrequest.method.aspx
0 comments:
Post a Comment