Exception
Explanation
The reason why you are getting this error is because while trying to access a JsonResult response via
a GET request, ASP.NET MVC protects you from JSON Hijacking
. for more information
about this vulnerability, see this entry.
Solution
There are two workarounds for this exception:
- Keep on accessing the action method via a POST request.
-
Allow HTTP GET requests by using JsonRequestBehavior enumeration like this:
public JsonResult Test() { string sensitiveInfo = "######"; return Json(sensitiveInfo, JsonRequestBehavior.AllowGet); }