I have a simple webservice that I would like to upload a file to. The problem is that I need the response in json.
Form my experience in order to get a response in Json my request has to have a content-type of 'application/json'. But ofcourse this cannot be the case with a file upload since the content type will have to be 'multipart/form-data'.
In my Json i want to return a value showing whether successful and a filename.
[WebMethod(EnableSession = true)]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public TyoeOfSomeObject UploadFile()
{
// Get the file from the context and do something with it
HttpPostedFile httpPostedFile = HttpContext.Current.Request.Files[0];
// Return either a string or an object to serialise with the required values
return SomeObject;
}