我已经使用 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?
任何帮助表示赞赏。