7

Is it possible to use ServiceStack Mini Profiler in self-hosted console application? If it is, where should I put profiler enable/disable code? In ASP.NET hosted ServiceStack it's usually in Application_BeginRequest and Application_EndRequest methods.

Louis Somers
  • 2,560
  • 3
  • 27
  • 57
Aleksandr Ivanov
  • 2,778
  • 5
  • 27
  • 35
  • 1
    when running ServiceStack in self-hosting mode, HttpContext.Current is always null. It seems that MiniProfiler relies on it. – migajek Jan 07 '14 at 12:20

2 Answers2

0

You could do it like this:

namespace ConsoleApplication1 {
  class Program {
    static void Main(string[] args) {
      // enable here

      // your code

      // disable here
    }
  }
}

or in the constructor and destructor like this:

namespace ConsoleApplication1 {
  class Program {
    Program() {
      // enable here
    }

    ~Program(){
      // disable here
    }

    static void Main(string[] args) {
      // your code
    }
  }
}
Louis Somers
  • 2,560
  • 3
  • 27
  • 57
  • can u put, more detail implementation, try using profiler.start on ctor and profiler.stop on dispose but no result out (js dialog as in web) – Anton Hasan Jun 05 '13 at 02:05
0
public abstract class MyHostBase : AppSelfHostBase
{
    this.GlobalRequestFilters.Add(OnBeginOfRequest);
    this.GlobalResponseFilters.Add(OnEnfOfRequest);
}
Hitesh
  • 3,449
  • 8
  • 39
  • 57