I have a MVC4 C# application that I want to allow a client to access through code (no browser or view). The client will send a user ID which will be used to look up a record and three fields will be returned. Both the incoming and outgoing data are sensitive information so I need a solution that is secure. The application is running on a site with SSL (https), will this protect me from JSON hijacking if I use a JSON solution as two answers have suggested?
public ActionResult InAction(string id)
{
// code to retrieve record and return three fields field1, field2, field3
return (what would go here?)
}
Can I even use a Controller Action to handle this? Do I need a full blown webservice to do this, if so any links to good MVC tutorials would be helpful?
The client works in ASP (webforms) and is talking about a responder page with key value pairs, how would I do the equivalent in MVC.
Any help on getting me going is greatly appreciated.
Thank you
UPDATE: I’ve marked Brett’s JSON suggestion as the answer. I am returning a string (not an array) and the entire transaction is taking place over a SSL connection so I believe the possibility of JSON hijacking is not an issue.
string response = field1 + "," + field2 + "," + field3;
return Json(response), JsonRequestBehavior.AllowGet; }
If I'm mistaken on that please let me know.