HTTP webclient or webrequest File post with variables

  • Thread starter Thread starter Matthew S
  • Start date Start date
M

Matthew S

Hello,
I'm looking to use the WebClient or HTTPWebRequest classes to post a data
file to an ASP.NET page.

While I know I could use the WebClient.UploadFile method, I am looking to
send 2 form variables along with the file data, unfortunately I don't see
an obvious way to do so.

Does anyone have a suggestion how I might accomplish this task? Or, how I
would format the POST data to represent these two variables and my
bytestream so I can submit that to my server-side page?

Thanks in advance.
 
Matthew said:
Hello,
I'm looking to use the WebClient or HTTPWebRequest classes to post a
data file to an ASP.NET page.

While I know I could use the WebClient.UploadFile method, I am
looking to send 2 form variables along with the file data,
unfortunately I don't see an obvious way to do so.

Does anyone have a suggestion how I might accomplish this task? Or,
how I would format the POST data to represent these two variables and
my bytestream so I can submit that to my server-side page?

That requires a multipart/form-data request. Unfortunately, there's no
built-in support for this in the FCL yet. You'll need to refer to RFC 2388
for more information.

Cheers,
 
Back
Top