ASP.NET Core MVC MiddlewareFilter exception not meaningful -
currently have problem thrown exceptions when enabling middlewarefilter. add filter developer exceptions quite meaningless (the complete stacktrace missing).
services.addmvc(options => options.filters.add(new middlewarefilterattribute(typeof(myfilter)))) public class myfilter { public void configure(iapplicationbuilder applicationbuilder, requestlocalizationoptions options) { applicationbuilder.userequestlocalization(options); } }
stacktrace filter:
system.exception: test exception @ microsoft.aspnetcore.mvc.internal.middlewarefilterbuilder.<>c.<<buildpipeline>b__8_0>d.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.localization.requestlocalizationmiddleware.<invoke>d__4.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokenextresourcefilter>d__22.movenext() --- end of stack trace previous location exception thrown --- @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.rethrow(resourceexecutedcontext context) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.next(state& next, scope& scope, object& state, boolean& iscompleted) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokeasync>d__20.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.builder.routermiddleware.<invoke>d__4.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.responsecompression.responsecompressionmiddleware.<invoke>d__3.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ simpleinjector.simpleinjectoraspnetcoreintegrationextensions.<>c__displayclass0_0.<<usesimpleinjectoraspnetrequestscoping>b__0>d.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swaggerui.swaggeruimiddleware.<invoke>d__5.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swaggerui.redirectmiddleware.<invoke>d__4.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swagger.swaggermiddleware.<invoke>d__6.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.diagnostics.statuscodepagesmiddleware.<invoke>d__3.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.visualstudio.web.browserlink.browserlinkmiddleware.<executewithfilter>d__7.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.cors.infrastructure.corsmiddleware.<invoke>d__7.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.diagnostics.developerexceptionpagemiddleware.<invoke>d__7.movenext()
stacktrace without filter:
system.exception: test exception @ myproject.myrepository.<fetch>d__9.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ system.runtime.compilerservices.taskawaiter.getresult() @ myproject.myhandler.<handle>d__7.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ system.runtime.compilerservices.taskawaiter`1.getresult() @ myproject.mycontroller.<index>d__19.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokeactionmethodasync>d__27.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokenextactionfilterasync>d__25.movenext() --- end of stack trace previous location exception thrown --- @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.rethrow(actionexecutedcontext context) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.next(state& next, scope& scope, object& state, boolean& iscompleted) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokenextresourcefilter>d__22.movenext() --- end of stack trace previous location exception thrown --- @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.rethrow(resourceexecutedcontext context) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.next(state& next, scope& scope, object& state, boolean& iscompleted) @ microsoft.aspnetcore.mvc.internal.controlleractioninvoker.<invokeasync>d__20.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.builder.routermiddleware.<invoke>d__4.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.responsecompression.responsecompressionmiddleware.<invoke>d__3.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ simpleinjector.simpleinjectoraspnetcoreintegrationextensions.<>c__displayclass0_0.<<usesimpleinjectoraspnetrequestscoping>b__0>d.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swaggerui.swaggeruimiddleware.<invoke>d__5.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swaggerui.redirectmiddleware.<invoke>d__4.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ swashbuckle.aspnetcore.swagger.swaggermiddleware.<invoke>d__6.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.diagnostics.statuscodepagesmiddleware.<invoke>d__3.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.visualstudio.web.browserlink.browserlinkmiddleware.<executewithfilter>d__7.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.cors.infrastructure.corsmiddleware.<invoke>d__7.movenext() --- end of stack trace previous location exception thrown --- @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task) @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernotification(task task) @ microsoft.aspnetcore.diagnostics.developerexceptionpagemiddleware.<invoke>d__7.movenext()
so i'm unable track down exceptions when enabling filter. have ideas how correct this? (i need use middlewarefilters)
after checking middlewarefilterbuilder implementation looks "expected" behavior...
// ideally want experience of middleware pipeline behave same if registered, // in startup. in scenario exception thrown in middelware later in pipeline gets propagated // earlier middleware. // check if later resource filter threw exception , propagate middleware pipeline. if (!resourceexecutedcontext.exceptionhandled && resourceexecutedcontext.exception != null) { throw resourceexecutedcontext.exception; }
that explains why see
system.exception: test exception @ microsoft.aspnetcore.mvc.internal.middlewarefilterbuilder.<>c.<<buildpipeline>b__8_0>d.movenext()
instead of
system.exception: test exception @ myproject.myrepository.<fetch>d__9.movenext()
also noticed, above code in dev branch, not in master branch in aspnet/mvc repo...
all seems candidate question/issue in mvc repo.
Comments
Post a Comment