2017-01-16 12 views
0

Azure Service FabricのASP.NETコアアプリケーションでWebListenerを使用したいと考えています。AzureサービスファブリックのASP.NETコアでWebListenerを使用する

私は次のようでしています

Task<string> ICommunicationListener.OpenAsync(CancellationToken cancellationToken) 
{ 
    var endpoint = FabricRuntime.GetActivationContext().GetEndpoint(_endpointName); 

    string serverUrl = $"{endpoint.Protocol}://{FabricRuntime.GetNodeContext().IPAddressOrFQDN}:{endpoint.Port}"; 

    _webHost = new WebHostBuilder().UseWebListener() 
       .UseContentRoot(Directory.GetCurrentDirectory()) 
       .UseStartup<Startup>() 
       .UseUrls(serverUrl) 
       .Build(); 

    _webHost.Start(); 

    return Task.FromResult(serverUrl); 
} 

生憎、これは動作しませんが。私は、Web APIのコントローラを作成し、私はこれを呼び出すときには、404

私はケストレルを使用する場合、それが動作を返します:

_webHost = new WebHostBuilder().UseKestrel() 
    .UseContentRoot(Directory.GetCurrentDirectory()) 
    .UseStartup<Startup>() 
    .UseUrls(serverUrl) 
    .Build(); 

これは私のprojects.jsonです:

{ 
"dependencies": { 
    "Microsoft.AspNetCore.Mvc": "1.0.1", 
    "Microsoft.AspNetCore.Routing": "1.0.1", 
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1", 
    "Microsoft.AspNetCore.Server.WebListener": "1.1.0", 
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0", 
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0", 
    "Microsoft.Extensions.Configuration.Json": "1.0.0", 
    "Microsoft.Extensions.Logging": "1.1.0", 
    "Microsoft.Extensions.Logging.Console": "1.0.0", 
    "Microsoft.Extensions.Logging.Debug": "1.0.0", 
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0", 
    "Microsoft.ServiceFabric": "5.3.301", 
    "Microsoft.ServiceFabric.Data": "2.3.301", 
    "Microsoft.ServiceFabric.Services": "2.3.301" 
}, 

"commands": { 
    "weblistener": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener" 
}, 

"tools": { 
}, 

"frameworks": { 
    "net452": { 
     "dependencies": { 
     } 
    } 
}, 

"buildOptions": { 
    "emitEntryPoint": true, 
    "preserveCompilationContext": true 
}, 

"publishOptions": { 
    "include": [ 
     "wwwroot", 
     "**/*.cshtml", 
     "appsettings.json", 
     "web.config" 
    ] 
}, 

"scripts": { 
} 
} 

私が足りません何か? Web Listenerを使用する理由は、ユーザーが手動でユーザー名とパスワードを入力する必要がないように、イントラネットアプリケーションでWindows認証を使用するためです。

答えて

1

このように、ワイルドカードのホストを使用してみてください:

string serverUrl = $"{endpoint.Protocol}://+:{endpoint.Port}"; 
関連する問題