Der folgende Ausnahmefilter leitet Ausnahmen zu meiner spezifischen Fehlerseite um.Ausnahmebestimmungen, die einen leeren Body in asp.net-core zurückgeben 1.1
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false)]
public class FrontofficeControllerExceptionFilterAttribute : ExceptionFilterAttribute
{
protected readonly ILogger<FrontofficeController> _logger;
protected readonly IHostingEnvironment _hostingEnvironment;
protected readonly IModelMetadataProvider _modelMetadataProvider;
public FrontofficeControllerExceptionFilterAttribute(ILogger<FrontofficeController> logger, IHostingEnvironment hostingEnvironment, IModelMetadataProvider modelMetadataProvider)
{
_logger = logger;
_hostingEnvironment = hostingEnvironment;
_modelMetadataProvider = modelMetadataProvider;
}
public override void OnException(ExceptionContext context)
{
if (context.ExceptionHandled) return;
Exception ex = context.Exception;
var result = new ViewResult { ViewName = "ApplicationError" };
context.ExceptionHandled = true; // mark exception as handled
context.Result = result;
}
}
Nach meinem Web-App zu asp.net Kern 1.1 das Ergebnis der Migration ist eine leere Seite: Der Körper der Antwort ist leer und Content-Length ist gleich Null. Dies ist die Antwort auf dem Client empfangen
HTTP/1.1 200 OK
Server: Kestrel
X-SourceFiles: =?UTF-8?B?QzpcUHJvamVjdHNcaW50ZXJhaC52aXN1YWxzdHVkaW8uY29tXEludmVudGFyaW9cTWFpblxTb3VyY2VcRnJvbnRvZmZpY2Vcc3JjXEZyb250b2ZmaWNl?=
X-Powered-By: ASP.NET
Date: Wed, 30 Nov 2016 14:49:53 GMT
Content-Length: 0
habe jemand ein ähnliches Problem erlebt und warum? danke für irgendeinen Kommentar
Ich lasse hier ein Update, wenn jemand das gleiche Problem hat: 1), beginnend mit einer frischen und leerer neuen App mit aspnetcore 1.0.1 der Seite korrekt 2) kommentiert die Zeile ‚wiedergegeben wird context.ExceptionHandled = wahr;' Die Seite wird gerendert so scheint es wirklich, dass das Problem mit asp.net core.1.1 und 'context.ExceptionHandled' ist –