Reputation: 7308
I am trying to have a HTML form post a file to a Asp .Net Web service method. Everything seems to work but there is no form or files on the request object in the web method. any ideas?
Html Form
<form id="formPost" action="service/Post" enctype="multipart/form-data" method="post">
Post File <input id="uploadfile" type=file />
<input type=submit value="Post" />
</form>
Web service
[WebMethod]
public void Post()
{
// file collection of uploaded files in the http context
HttpFileCollection Files = this.Context.Request.Files;
// always 0 and no form either
if (Files.Count > 0)
{}
}
Upvotes: 0
Views: 2450
Reputation: 1038720
You cannot post to a SOAP web service method using html form. When you submit the form data is encoded using multipart/form-data
while a web service expects a SOAP envelope and text/xml
content type. In order to invoke the web service you will need to generate a proxy class from the WSDL and use this proxy class to call the desired method.
Upvotes: 2