I’m not sure what exactly do the Application_Start and End do. However, if you want to execute something during the application launch, you cannot access IDotvvmRequestContext, since there is no request running yet.
Why do you need a request for logging, isn’t access to IServiceProvider enough? If yes, you can get it from DotvvmConfiguration.ServiceProvider inside the DotvvmStartup or in the OWIN Startup class.
var config = app.UseDotVVM<DotvvmStartup>(...);
Also, as far as I remember, Serilog is configured a singleton instance, which you can access as Serilog.Log from anywhere. The configuration can be done Startup.Configure on OWIN, or just in Program.Main on AspNetCore.
When it comes to
Application_End, I only remember that AspNetCore calls StopAsync method on all
IHostedService (it also has asynchronous Start in case you’d need that). There are simpler events, though, AspNetCore: c# - How do I register code to run when shutting down an ASP.NET web application using the new .NET 6 format? - Stack Overflow, OWIN: asp.net - Is there Application_End from Global.asax in Owin? - Stack Overflow
Application_Error can most likely be replaced by the
ActionFilterAttribute, it depends what exactly do you need, it’s perfect if you want to log error from DotVVM pages. Inherit the
ExceptionFilterAttribute and override the
There is also
OnCommandExceptionAsync. Maybe the
OnCommandExceptionAsync might be useful for you, since you might want to log the command binding which failed (
OnCommandExceptionAsync method is often used to handle the error and set some view model property to display an error message (Exception filters | DotVVM Documentation), if you do this, you’ll not see an exception in
OnPresenterExceptionAsync. Otherwise, these events are just more specific - only called when GET / postback fails, and have the advantage of being called before view model is disposed.