Click here to Skip to main content
15,908,675 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have two MVC Application each having two different controller with jsonresult method .'

I want to pass json string object using httpclient is it possible ?

MVC Application1:

public class ProcessCheckController : Controller
{
public JsonResult Process(string value)
{

object Response = value;
}
}

MVC Application 2 which calls the Process Action method of ProcessCheckController Controller of mVC Application 1.


C#
public ActionResult Index()
        {
            var client = new HttpClient();
            string str= PrepareString();
            var response = client.PostAsJsonAsync("http://localhost:19308/ProcessCheck/Process/", str).Result;
            var value = response.Content.ReadAsStringAsync().Result;

            //var result = JsonConvert.DeserializeObject<List<Photo>>(value);

            var result = JsonConvert.DeserializeObject(value);

            return View(result);
        }


 private string PrepareString()
        {
            string fname = "Test";



            return "{\"Data\":{\"FirstName\":\"" + fname +
                   "\",\"LastName\":\"" + fname +
                   "\",\"MiddleName\":\"" + fname +
                   "\",\"EmailAddress\":\"" + fname +
                   "\",\"Ssn\":\"" + fname +
                   "\",\"DateOfBirth\":\"" + fname +
                   "\",\"MonthlyNetIncome\":\"" + fname +
                   "\",\"MobileNo\":\"" + fname + "\"}}";
        }
Posted
Updated 4-Sep-13 6:50am
v2
Comments
Jameel VM 4-Sep-13 12:59pm    
try by using HttpWebRequest

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900