简体   繁体   English

在自托管控制台应用程序中使用ServiceStack Mini Profiler

[英]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_BeginRequestApplication_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.

相关问题 具有每个请求生存期范围的ServiceStack自托管应用程序 - ServiceStack self-hosted application with per-request lifetime scope 自托管服务器中的ServiceStack会话为null - ServiceStack Session is null in self-hosted server 自托管 .NET 核心控制台应用程序中的 Startup.cs - Startup.cs in a self-hosted .NET Core Console Application 具有嵌入式images / css的ServiceStack Razor(自托管) - ServiceStack Razor (self-hosted) with embedded images/css WCF“自托管”应用程序变得无法响应 - WCF “Self-Hosted” application becomes unresponsive 在自托管的c#WCF控制台应用程序中使用web.config(设置MaxStringContentLength服务器端) - Using web.config in a Self-Hosted c# WCF console app (setting MaxStringContentLength server side) 自托管 Net Core 3 应用程序不采取端口设置 - Self-hosted Net Core 3 application does not take port settings 在多个Web应用程序工作进程中运行自托管的WCF - Running WCF self-hosted in multiple web application worker processes 保持自托管服务堆栈服务作为docker swarm服务打开,而不使用控制台readline或readkey - Keep a self hosted servicestack service open as a docker swarm service without using console readline or readkey 自托管 SQL 数据库 (LocalDB) 与 UWP 应用程序 - Self-hosted SQL database (LocalDB) with UWP application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM