Im trying to upload camera taken photo to webservice with afnetworking.
this my upload part code :
CGSize newSize = CGSizeMake(500.0f, 500.0f);
UIGraphicsBeginImageContext(newSize);
[_imagedata drawInRect:CGRectMake(0,0,newSize.width,newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSData *imgData = UIImageJPEGRepresentation(newImage, 0.9f);
    AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
    NSDictionary *parameters = @{@"user": "test_user"};
    [manager POST:@"http://www.mywebsite.com/webservice.aspx" parameters:parameters constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
        manager.responseSerializer = [AFHTTPResponseSerializer serializer];
        [formData appendPartWithFormData:imgData name:@"image"];
    } success:^(AFHTTPRequestOperation *operation, id responseObject) {
        NSLog(@"Success: %@", responseObject);
    } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
        NSLog(@"Error: %@", error);
    }];
Im using Asp.net as my webservice.
this is my server side code :
    string USER = Server.UrlDecode(Request["user"]),
    SqlParameter prmUser = sc.Parameters.Add("@user", SqlDbType.VarChar);
    prmUser.Direction = ParameterDirection.Input;
    prmUser.Value = USER;
    HttpFileCollection MyFileCollection = Request.Files;
    if (MyFileCollection != null && MyFileCollection.Count > 0 && MyFileCollection[0] != null)
    {
        SqlParameter prmImage = sc.Parameters.Add("@Image", SqlDbType.Image);
        prmImage.Direction = ParameterDirection.Input;
        byte[] buf = new byte[MyFileCollection[0].ContentLength];
        MyFileCollection[0].InputStream.Read(buf, 0, MyFileCollection[0].ContentLength);
        prmPhoto.Value = buf;
    }
sc.ExecuteNonQuery();
now everytime i run program this error apears :
Error: Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo=0x1555ff60 {com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x16a94010> { URL: http://www.mywebsite.com/webservice.aspx } { status code: 500, headers {
    Connection = close;
    "Content-Length" = 3420;
    "Content-Type" = "text/html; charset=utf-8";
    Date = "Wed, 01 Apr 2015 15:56:21 GMT";
    Server = "Microsoft-IIS/8.5";
    Via = "1.1 magellan-front (squid/3.5.1)";
    "X-AspNet-Version" = "4.0.30319";
    "X-Cache" = "MISS from magellan-front";
    "X-Powered-By" = "ASP.NET";
} }, NSErrorFailingURLKey=http://www.mywebsite.com/webservice.aspx, NSLocalizedDescription=Request failed: internal server error (500),
the detailed error :
[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (image="...�5�Ƨ&�����<I
�(�ep��K�,�=mp�...").]
also the webservice works well with android HttpFileUpload method.
 
     
     
    