'System.InvalidOperationException: Request format is invalid: multipart/form-data' error when posting image from iphone to .NET webservice

I got this to work by moving these to lines in web.config:

<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

They where placed in the bottom of the <system.webServer><handlers> section in web.config, but since I moved them to the top it seems to work!


You are trying to read binary data as input parameters. You need to instead read the parameters from Context.Request. In other words, remove userToken and image as Request Parameters. userToken should be instead accessed through Context.Request["userToken"] and image should be available through Context.Request.PostedFiles["image"]: http://www.rahulsingla.com/blog/2010/07/ext-net-ajax-file-upload-using-web-service