0
我有在代碼中的WebAPI服務,在應用程序啓動運行此配置:WCF的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>
你是怎麼知道它是CTP而不是最終版本的?是因爲我提到它還是代碼中有不同的東西?另外,我不需要在代碼和錯誤處理程序中添加一些等同於CreateInstance位的配置嗎? – kabaros
只是添加到我的評論,對System.ServiceModel的任何引用意味着它使用WCF ..並且我們不需要添加CreateInstance位(錯誤處理程序可以以與MVC應用程序相同的方式完成) – kabaros