Can I use ServiceStack Mini Profiler in a standalone console application? If so, where should I put the profiler to enable / disable the code? In ASP.NET hosted by ServiceStack, it is commonly used in Application_BeginRequest and Application_EndRequest .
You can do it as follows:
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { // enable here // your code // disable here } } }
or in the constructor and destructor:
namespace ConsoleApplication1 { class Program { Program() { // enable here } ~Program(){ // disable here } static void Main(string[] args) { // your code } } }
public abstract class MyHostBase : AppSelfHostBase { this.GlobalRequestFilters.Add(OnBeginOfRequest); this.GlobalResponseFilters.Add(OnEnfOfRequest); }