【问题标题】:Service Fabric ASP.Net core Stateful reliable service giving This localhost page can’t be found errorService Fabric ASP.Net core Stateful 可靠服务给 This localhost page can't be found 错误
【发布时间】:2019-10-05 16:35:28
【问题描述】:

我是 Azure Service Fabric 的新手,我正在尝试使用 VS2017 在 Service Fabric 上运行它。

我创建了一个服务结构应用程序并添加了 ASP.Net 核心状态完全可靠的服务。 当我运行它(核心应用程序没有任何更改)时,我收到错误

找不到此本地主机页面(HTTP 错误 410)

我不确定缺少什么,有人可以帮忙吗?

我尝试在 Kestrel 和 Web 侦听器之间切换 关注ASP.NET Core This localhost page can’t be found

我在 asp.net core startup.cs 中添加了

app.UseMvc(routes => {
                routes.MapRoute(name: "default", template: "{controller}/{action=Index}/{id?}");
            });

我没有更改 lauchsettings.json 中的任何内容

在我有的 CreateServiceReplicaListeners 中(我也收到与默认 Kestrel 列表器相同的错误):

return new ServiceReplicaListener[]
{
    new ServiceReplicaListener(serviceContext =>
        new HttpSysCommunicationListener(serviceContext, "ServiceEndpoint",  (url, listener) =>
        {
            ServiceEventSource.Current.ServiceMessage(serviceContext, $"Starting web server {url}");

            return new WebHostBuilder()
                        .UseHttpSys()
                        .ConfigureServices(
                            services => services
                                .AddSingleton<StatefulServiceContext>(serviceContext)
                                .AddSingleton<IReliableStateManager>(this.StateManager))
                        .UseContentRoot(Directory.GetCurrentDirectory())
                        .UseStartup<Startup>()
                        .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
                        .UseUrls(url)
                        .Build();
        }))
}; 

**In serviceManifest.xml**
<Resources>
    <Endpoints>
      <Endpoint Port="8052" Protocol="http" Name="ServiceEndpoint"  Type="Input"/>
    </Endpoints>
</Resources>

http://localhost:8052/

【问题讨论】:

    标签: azure localhost azure-service-fabric asp.net-core-webapi


    【解决方案1】:

    使用ServiceFabricIntegrationOptions.None 而不是ServiceFabricIntegrationOptions.UseUniqueServiceUrl

    后者用于动态端口分配。

    使用动态端口分配,此设置可防止错误 前面描述的身份问题。

    更多信息here

    注意:不建议在stateful服务中使用HttpSys。

    HttpSysCommunicationListener 目前并非设计用于 由于底层 HTTP.sys 的复杂性导致的有状态服务 端口共享功能。有关详细信息,请参阅以下部分 关于使用 HTTP.sys 进行动态端口分配。对于有状态的服务, Kestrel 是建议的 Web 服务器。

    【讨论】:

      猜你喜欢
      • 2016-12-13
      • 2016-07-26
      • 2016-02-17
      • 2017-12-01
      • 2018-03-11
      • 2017-06-26
      • 2018-09-15
      • 2016-08-30
      • 1970-01-01
      相关资源
      最近更新 更多