0

I have this configuration for a WebApi service in code that runs on Application start:

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())
};

Now, I want to move this out of code and do it in web.config. what will the equivalent be? I have this so far under runtime in web.config, I am not sure if it's correct and also I don't know what CreateInstance and ErrorHandlers would translate to in configuration:

<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>
carlosfigueira
  • 85,035
  • 14
  • 131
  • 171
kabaros
  • 5,083
  • 2
  • 22
  • 35

1 Answers1

0

It's correct.

But you are using WCF Web API, what is actually CTP version of ASP.NET Web API, so I suggest you to migrate to it. It's not hard to do, because they are similar.

And one more reason to migrate is, when I was using WCF Web API, configuring HTTPS and security using config, didn't worked by me. Configuring programmatically worked. So I think it was some kind of bug.

Regfor
  • 8,515
  • 1
  • 38
  • 51
  • how did you know it's CTP not final version. Is it just because I mentioned it or is there something different in the code? Also don't I need to add some configuration equivalent to CreateInstance bit in the code and the error handler? – kabaros Oct 10 '12 at 20:55
  • just to add to my comment, any reference to System.ServiceModel means it's using WCF .. and we don't need to add the CreateInstance bit (error handler can be done the same way as with MVC applications) – kabaros Oct 26 '12 at 13:12