を開催し、私は次のコードASP.NETのActionResultがローカルホストとAzureのWebサービスごとに異なる応答が
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");
}
}
を持っていますので、呼び出しは以下の結果、そう
{
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
}
を返し、私はdata
を取得しますJSONの内部でerror
を探して、値(An error occured
)をアラートとして表示します。
が、Azureのアプリケーションサービスにこれを展開して実行すると、応答が意味
{
config : {method: "GET", transformRequest: Array(1), transformResponse: Array(1), jsonpCallbackParam: "callback", paramSerializer: ƒ, …}
data : "Bad Request"
headers : ƒ (name)
status : 400
statusText : "Bad Request"
__proto__ : Object
}
以下のように来て、私はdata
内部error
を見つける傾けます。なぜこのように振る舞うのですか?
私の最初の推測では、デバッグがローカルに有効にしていると、例外の詳細を返さないのAzureでのリリースバージョンを展開しているだろうか?例外は情報漏えいの可能性があるので、これは良いことです。 –
@RickvandenBoschは、デバッグ設定でアプリケーションをデプロイしても同じ動作をします –