我正在尝试使用内置错误处理属性HandleError
来处理错误。它按预期处理错误,只是通过抛出错误消息知道错误但是然后发生错误,这不是期望的,并且没有处理它发送默认错误消息。而不是它我想在未处理的异常发生时显示一个通用消息。
[HandleError]
public async Task<ActionResult> Index(string operation, string returnUrl, string salt, string sig, string userId, string productId, string subscriptionId)
{
throw new Exception("Test Error");
if (Request.QueryString.Count == 0) return Redirect("/Portal"); //RedirectToAction("Index", "Error", new { message = "Forbidden" });
var url = Request.UrlReferrer;
//TODO: move these to settings store (Configuration) Configuration should be based on per sender (Referrer)
if (operation.ToLowerInvariant() == "signin" || operation.ToLowerInvariant() == "subscribe")
{
var signature = productId == null ? "\n" + returnUrl : "\n" + productId + "\n" + userId;
var check = _apimHandler.CheckHash(salt + signature, sig, _delegationValidationKey);
if (!check)
{
return new HttpStatusCodeResult(HttpStatusCode.ExpectationFailed, "Invalid Token");
}
}
}