Tüm özel durumları işlemek ve günlüğe kaydetmek için genel bir eylem filtresi kullanıyorum. o OnException
yöntemini geçersiz kılar -ExceptionContext.ExceptionGandled değişiklikleri doğru. Özel durum nerede ele alınır?
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
{
filters.Add(new ElmahHandleErrorAttribute());
filters.Add(new HandleErrorAttribute());
}
Bu küresel eylem filtresi ElmahHandleErrorAttribute
tanımlanır nasıl. OnException
yöntemi çalıştırılır zaman context.ExceptionHandled
değeri doğrudur neden
public class ElmahHandleErrorAttribute : System.Web.Mvc.HandleErrorAttribute
{
public override void OnException(ExceptionContext context)
{
//Is the exception handled already? context.ExceptionHandled seems to be true here
if (!context.IsChildAction && (context.HttpContext.IsCustomErrorEnabled))
{
//Do other stuff stuff
//Log to Elmah
}
}
...
}
anlamıyorum. Bu istisna nasıl ele alınır?
-EDIT-
BenWeb.Config
bir
customErrors
bölümü var. Bir
ErrorController
sınıfım var ve
General
ve
Http404
adlı eylemler var.
ElmahHandleErrorAttribute
başlar
OnException
yöntemi çalıştırırken, ancak
ExceptionContext.ExceptionHandled
değeri true olarak ayarlanır Ne (kesme noktası isabet asla), kontrolör eylem
General
yürütülmez olduğunu anlamıyorum
<customErrors mode ="On" defaultRedirect="Error/General">
<error statusCode="404" redirect="Error/Http404"/>
</customErrors>
.
Kodunuzda 'context.ExceptionHandled' göremiyorum, nerede? – gdoron
@gdoron context.ExceptionHandled için denetimi kaldırdım.Daha önce ifadeye dahil edildi: 'if (! Context.IsChildAction &&! Context.ExceptionHandled && (context.HttpContext.IsCustomErrorEnabled)) – escist
Denetleyicinin' OnException' yöntemini geçersiz kıldınız mı? – gdoron