I have the following code
public ActionResult PerformMagic(string a, string b, int c)
{
try
{
// Some code which always gives an error and go to catch block
}
catch (Exception ex)
{
// ex.Message = "An error occured"
Response.StatusCode = (int)HttpStatusCode.BadRequest;
return this.Content(System.Web.Helpers.Json.Encode(new { error = ex.Message }), "application/json");
}
}
So the call returns the below result,
{
config : {method: "GET", transformRequest: Array(1), transformResponse: Array(1), jsonpCallbackParam: "callback", paramSerializer: ƒ, …}
data :
error : "An error occured"
__proto__ : Object
headers : ƒ (name)
status : 400
statusText : ""
__proto__ : Object
}
So, I get the data inside the JSON, look for error and display the value (which is An error occured) as an alert.
This works perfectly when running in localhost, but when deploy this to Azure App service and run, the response comes as below
{
config : {method: "GET", transformRequest: Array(1), transformResponse: Array(1), jsonpCallbackParam: "callback", paramSerializer: ƒ, …}
data : "Bad Request"
headers : ƒ (name)
status : 400
statusText : "Bad Request"
__proto__ : Object
}
That means, I cant find error inside data. Can anyone explain me why this behaves like this?
