相关疑难解决方法(0)

Windows 服务应用程序中自托管 ASP.NET Web API 的问题

我在网上看到了一些文章,描述了如何在 Windows 服务应用程序中自行托管 ASP.NET Web API(请参阅此处此处)。我在 VB.NET 中编写了一些简单的代码,以便在服务启动时启动自主机,并在服务停止时停止它,如下所示:

Protected Overrides Sub OnStart(ByVal args() As String)
    Try
        ' init a new self host configuration using the base address
        _config = New HttpSelfHostConfiguration(New Uri("http://localhost:8080"))

        ' map the URLs into the config
        MapRoutes(_config)

        _server = New HttpSelfHostServer(_config)
        ' start the server and wait for requests
        _server.OpenAsync()

    Catch ex As Exception
        Throw
    End Try
End Sub

Protected Overrides Sub OnStop()
    Try
        _server.CloseAsync().Wait()
        _server.Dispose()
    Catch ex As Exception
        Throw
    End Try …
Run Code Online (Sandbox Code Playgroud)

vb.net asp.net-web-api

5
推荐指数
1
解决办法
3822
查看次数

为什么要在Kestrel中使用代理服务器?

官方的MS文档说,如果我想在Linux上托管ASP.NET核心应用程序,则应该在其前面放置一个apache或nginx反向代理。但是,我找不到我应该这样做的任何理由。

我为什么要那样做?为什么不能仅在茶est上运行?为什么需要反向代理?

apache nginx .net-core asp.net-core

3
推荐指数
1
解决办法
1552
查看次数