WCF Web API を使用して安らかなサービスを実装しており、IIS で公開したいと考えています。開発プロセス中、私はサービスをコンソール アプリケーションとして使用し、すべての構成は API を介して行われました。現在、サービスを ASP.NET アプリケーションとして公開しようとしていますが、すべての構成を Web 構成ファイルに移動するしか方法がありません。
コード化された構成は次のとおりです。
var cfg = HttpHostConfiguration.Create()
.AddMessageHandlers(typeof(AllowCrossDomainRequestHandler));
using (var host = new HttpConfigurableServiceHost(typeof(RESTfulService), cfg , new Uri("http://localhost:8081")))
{
var endpoint = ((HttpEndpoint)host.Description.Endpoints[0]); //Assuming one endpoint
endpoint.TransferMode = TransferMode.Streamed;
endpoint.MaxReceivedMessageSize = 1024 * 1024 * 10; // Allow files up to 10MB
host.Open();
Console.WriteLine("Host opened at {0} , press any key to end", host.Description.Endpoints[0].Address);
Console.ReadKey();
}
この構成を反映するには、私の web.config はどのように見えるべきですか? または、ASP.NET を使用する代わりに他のアプローチはありますか?
どんな助けでも大歓迎です。