[英]Using ServiceStack Mini Profiler in self-hosted console application
Is it possible to use ServiceStack Mini Profiler in self-hosted console application? 是否可以在自托管控制台应用程序中使用ServiceStack Mini Profiler? 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.
在ASP.NET托管的ServiceStack中,它通常位于Application_BeginRequest和Application_EndRequest方法中。
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
}
}
}
public abstract class MyHostBase : AppSelfHostBase
{
this.GlobalRequestFilters.Add(OnBeginOfRequest);
this.GlobalResponseFilters.Add(OnEnfOfRequest);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.