我已经尝试实施其他问题的一些建议来解决这个令人沮丧的问题。通常,当我在 IIS 中设置站点时,Web 应用程序对传输层发生的事情有些“不可知”。但是,对于这个特定的应用程序,当我应用 https 绑定时,我无法让它工作。
我的 web.config 看起来像:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<bindings>
<basicHttpBinding>
<binding name="DefaultAPIBinding">
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
我的 Global.asax.cs 看起来像
ContainerBuilder builder = new ContainerBuilder();
//builder.Register<IContactRepository, ContactRepository>();
builder.Register<IResourceFactory, Classes.LightCoreResourceFactory>();
IContainer container = builder.Build();
var configuration = HttpHostConfiguration.Create().SetResourceFactory(new LightCoreResourceFactory(container));
RouteTable.Routes.MapServiceRoute<WebServiceResources>("ws", configuration);
但是每当我将https
绑定添加到我的 IIS 站点时,我都会收到错误消息:
The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress
[ArgumentException: The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress]
System.ServiceModel.Channels.TransportChannelListener..ctor(TransportBindingElement bindingElement, BindingContext context, MessageEncoderFactory defaultMessageEncoderFactory, HostNameComparisonMode hostNameComparisonMode) +12800194
System.ServiceModel.Channels.HttpChannelListener..ctor(HttpTransportBindingElement bindingElement, BindingContext context) +41
System.ServiceModel.Channels.HttpChannelListener`1..ctor(HttpTransportBindingElement bindingElement, BindingContext context) +28
System.ServiceModel.Channels.HttpTransportBindingElement.BuildChannelListener(BindingContext context) +133
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener() +63
Microsoft.ApplicationServer.Http.Channels.HttpMessageEncodingBindingElement.BuildChannelListener(BindingContext context) +90
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener() +63
Microsoft.ApplicationServer.Http.Channels.HttpMessageHandlerBindingElement.BuildChannelListener(BindingContext context) +158
System.ServiceModel.Channels.BindingContext.BuildInnerChannelListener() +63
System.ServiceModel.Channels.Binding.BuildChannelListener(Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, BindingParameterCollection parameters) +125
System.ServiceModel.Description.DispatcherBuilder.MaybeCreateListener(Boolean actuallyCreate, Type[] supportedChannels, Binding binding, BindingParameterCollection parameters, Uri listenUriBaseAddress, String listenUriRelativeAddress, ListenUriMode listenUriMode, ServiceThrottle throttle, IChannelListener& result, Boolean supportContextSession) +336
System.ServiceModel.Description.DispatcherBuilder.BuildChannelListener(StuffPerListenUriInfo stuff, ServiceHostBase serviceHost, Uri listenUri, ListenUriMode listenUriMode, Boolean supportContextSession, IChannelListener& result) +716
System.ServiceModel.Description.DispatcherBuilder.InitializeServiceHost(ServiceDescription description, ServiceHostBase serviceHost) +1131
System.ServiceModel.ServiceHostBase.InitializeRuntime() +65
System.ServiceModel.ServiceHostBase.OnBeginOpen() +34
System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout) +50
System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout) +310
System.ServiceModel.Channels.CommunicationObject.Open() +36
System.ServiceModel.HostingManager.ActivateService(ServiceActivationInfo serviceActivationInfo, EventTraceActivity eventTraceActivity) +91
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath, EventTraceActivity eventTraceActivity) +598
[ServiceActivationException: The service '/ws' cannot be activated due to an exception during compilation. The exception message is: The provided URI scheme 'https' is invalid; expected 'http'.
Parameter name: context.ListenUriBaseAddress.]
System.Runtime.AsyncResult.End(IAsyncResult result) +495736
System.ServiceModel.Activation.HostedHttpRequestAsyncResult.End(IAsyncResult result) +178
System.ServiceModel.Activation.AspNetRouteServiceHttpHandler.EndProcessRequest(IAsyncResult result) +6
System.Web.CallHandlerExecutionStep.OnAsyncHandlerCompletion(IAsyncResult ar) +129
由于错误消息未在我的代码中提供要检查的位置或任何其他提示,并且由于我已经实施了有关如何解决此问题的其他一些建议,因此我不知所措。知道我可以做些什么来使这个应用程序允许https
绑定吗?