Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8249897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T23:42:03+00:00 2026-06-07T23:42:03+00:00

I am trying to POST JSON data to my asp.net MVC server from an

  • 0

I am trying to POST JSON data to my asp.net MVC server from an iPhone app. The method in my server looks like this:

[HttpPost]
public String MyMethod(Stream anUpload) { ... }

And here is the code to POST the JSON from my app:

NSString *theURL = [NSString stringWithFormat:@"http://192.168.1.103/MyServer/MyMethod"];
NSMutableURLRequest *theRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:theURL]];
[theRequest setHTTPMethod:@"POST"];

// Serialize my data.
NSData *theData = [NSJSONSerialization dataWithJSONObject:theList options:kNilOptions error:nil];

[theRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[theRequest setValue:@"application/json" forHTTPHeaderField:@"Accept"];
[theRequest setValue:[NSString stringWithFormat:@"%d", [theData length]] forHTTPHeaderField:@"Content-Length"];
[theRequest setHTTPBody:theData];

However, when I send the request, I just get an error message from the server, the MyMethod() never gets called. I am assuming that there is an issue with ASP accepting the POST data. Any ideas?

EDIT: Answer below

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T23:42:06+00:00Added an answer on June 7, 2026 at 11:42 pm

    I found the answer:

    I just needed to change the server-side function to

    public String MyMethod(List<string> aList) { ... }

    The ModelBinder was trying to deserialize the JSON for me, and it didn’t like my parameter being a Stream.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to receive some json from my asp.net mvc webservice. ASP.NET: public JsonResult
I am trying to send some JSON data to my ASP.NET MVC3 controller action
Im trying to run a sipmle ASP.NET 2 Webmethod with JSON this is my
I am trying to use a web service built on asp.net wcf from iPhone
How to post JSON data using HttpURLConnection? I am trying this: HttpURLConnection httpcon =
I'm trying to test a JAX-RS by doing a POST of JSON data from
I just copied some code from an asp.net mvc 2 app which works. Now
I have an ASP.NET MVC Form, but the data from it needs to be
I'm trying to call an asp.net method using jquery/ajax from a button click on
This is my first time attempting to call an ASP.NET page method from jQuery.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.