有谁知道这会在最终版本中发生多大变化,因为这是他们说会改变的领域之一?解决方法 要支持httpS,您需要在httpBinding上启用传输安全性.这可以通过从httpConfigurableServiceHostFactory派生并覆盖CreateServiceHost来完成:
public class HypertextTransferProtocolSecureServiceHostFactory : httpConfigurableServiceHostFactory{ protected overrIDe ServiceHost CreateServiceHost(Type serviceType,Uri[] baseAddresses) { var configurationBuilder = httpHostConfiguration.Create(); var host = new httpConfigurableServiceHost(serviceType,configurationBuilder,baseAddresses); foreach (var endpoint in host.Description.Endpoints.Where(e => e.ListenUri.Scheme == "https")) { var binding = endpoint.Binding as httpBinding; if (binding != null) { binding.Security.Mode = httpBindingSecurityMode.Transport; } } return host; }}
最后,必须将HypertextTransferProtocolSecureServiceHostFactory添加到Routetable:
Routetable.Routes.Add(new ServiceRoute("routePrefix",new HypertextTransferProtocolSecureServiceHostFactory(),typeof(ServiceType)));总结
以上是内存溢出为你收集整理的WCF Web API安全性全部内容,希望文章能够帮你解决WCF Web API安全性所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)