Using ServiceStack Mini Profiler in self-hosted console application
Asked Answered
A

2

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.

Anguiano answered 6/5, 2013 at 21:19 Comment(1)
when running ServiceStack in self-hosting mode, HttpContext.Current is always null. It seems that MiniProfiler relies on it.Acroter
C
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
    }
  }
}
Cycle answered 7/5, 2013 at 16:51 Comment(1)
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)Emissive
A
0
public abstract class MyHostBase : AppSelfHostBase
{
    this.GlobalRequestFilters.Add(OnBeginOfRequest);
    this.GlobalResponseFilters.Add(OnEnfOfRequest);
}
Allyce answered 27/10, 2014 at 10:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.