我在应用程序启动时运行的代码中有一个 WebApi 服务的配置:
var configuration = new WebApiConfiguration
{
Security = (uri, binding) => {
binding.Mode = HttpBindingSecurityMode.TransportCredentialOnly;
binding.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
},
CreateInstance = ((type, requestMessage, o) => container.Resolve(type)),
ErrorHandlers = (handlers, endpoint, description) => handlers.Add(new GlobalErrorHandler())
};
现在,我想将其从代码中移出并在 web.config 中进行。等价物是什么?到目前为止,我在 web.config 运行时有这个,我不确定它是否正确,而且我不知道 CreateInstance 和 ErrorHandlers 在配置中会转换成什么:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="basicHttp">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows"></transport>
</security>
</binding>
</basicHttpBinding>
</bindings>
<client />
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true">
</serviceHostingEnvironment>
</system.serviceModel>