Click here to Skip to main content
15,879,535 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All ,

In My project i have two ActionResult Methods in my Controller. The first ActionResult method is retrieving a Json from an Ajax call.

ActionResult Method1 is something like this:....

C#
public ActionResult VehicleModel(int id)
      {
          var vehicle = myService.VehicleModel(id);
          myserviceService.Close();

          return Json(new { model = vehicle }, JsonRequestBehavior.AllowGet);
      }


ActionResult Method2

C#
public ActionResult Vehicles(string id,  string vehicle)
        {

            var _cat = _catalogue.Data.FirstOrDefault(x => x.manufacturerId == id && x.Vehicle == vehicle);
            ViewData["id"] = id;
            return PartialView("_vehicle", _cat);
        }



Now .. I would i gain access to Method 1 in method 2? What i would to do is get the json returned in method (vehicle) and pass as a parameter in Method2.. I am not so sure on how i would go about in achieving this.. Please help.

Thank you
Posted
Comments
F-ES Sitecore 2-Nov-15 6:08am    
Method 1 returns an ActionResult which you can't really use in method two. If it's the vehicle object you want then create a function that returns a car for a given id, and then method and method 2 can both call that function.
Nathan Minier 2-Nov-15 8:37am    
Well, really it's a JSONResult and you could apply reflection to the Data property in order to recover a result.

Which seems like a lot more trouble than it's worth.

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