Click here to Skip to main content
Sign Up to vote bad
good
See more: C#ASP.NETC#4.0MVC
In the client I write the code like this:
static void Main(string[] args)
{
    var url = "http://www.cnblogs.com/api/say";
 
    var postData = new Dictionary<string, string>
    {
        { "username", "test" },
        { "words", "hello world" }
    };
 
    var urlEncodedContent = new FormUrlEncodedContent(postData);
    var httpClient = new HttpClient();
    var result = httpClient.PostAsync(url, urlEncodedContent).Result.Content.ReadAsStringAsync().Result;
    Console.WriteLine(result);
}
 
But in the mvc controller( as server),How to receieve the dictionary called postData and return the client statuscode?
Posted 4 hrs ago
zqliu352


1 solution

In terms of MVC, the method name might be "Say", which is accepting the parameters username, words. If you are missing this mapping then you cannot receive the posted data from client side on server side.
Just for better understanding, check this : Sample
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Sergey Alexandrovich Kryukov 585
1 Maciej Los 395
2 OriginalGriff 345
3 Dave Kreskowiak 325
4 Mohammed Hameed 303
0 Sergey Alexandrovich Kryukov 5,619
1 OriginalGriff 4,532
2 CPallini 2,667
3 Róhãn Lëuvä 2,337
4 Tadit Dash 1,443


Advertise | Privacy | Mobile
Web04 | 2.6.130513.1 | Last Updated 13 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid