简体   繁体   English

提供的URI方案“ https”无效

[英]The provided URI scheme 'https' is invalid

I have tried implementing a number of suggestions from other questions to fix this frustrating issue. 我尝试实施其他问题的一些建议来解决此令人沮丧的问题。 Normally, when I set up a site in IIS, the web apps are somewhat "agnostic" to what is going on at the transport layer. 通常,当我在IIS中设置站点时,Web应用程序与传输层上发生的事情有些“无关”。 However, for this particular app, I cannot get it to work when I apply an https binding. 但是,对于这个特定的应用程序,当我应用https绑定时,无法使其正常工作。

My web.config looks like: 我的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>

and my Global.asax.cs looks like 我的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);

But whenever I add an https binding to my IIS site, I get the error: 但是,每当我向IIS站点添加https绑定时,都会收到错误消息:

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

Since the error message does not provide a location in my code to check or any other hints, and since I have already implemented some of the other suggestions on how to fix this, I am at a loss. 由于错误消息未在我的代码中提供要检查的位置或任何其他提示,并且由于我已经实现了有关如何解决此问题的其他建议,所以我很茫然。 Any idea of what I can do to make this app allow https bindings? 关于如何使该应用程序允许https绑定的任何想法?

To elaborate on what @thedr said, here is what we did: 为了详细说明@thedr的内容,这是我们所做的:

  1. Upgrade to MVC4 if you have not done so already 尚未升级到MVC4
  2. Add the following class ripped straight from this CodePlex discussion 添加从此CodePlex讨论中直接摘录的以下类
 public class HttpsServiceHostFactory : HttpConfigurableServiceHostFactory { public override ServiceHostBase CreateServiceHost(string constructorString, Uri[] baseAddresses) { var host = base.CreateServiceHost(constructorString, baseAddresses); foreach (var httpBinding in from serviceEndpoint in host.Description.Endpoints where serviceEndpoint.ListenUri.Scheme == "https" select (HttpBinding)serviceEndpoint.Binding) { httpBinding.Security.Mode = HttpBindingSecurityMode.Transport; } return host; } } 

Then when you do RouteTable.Routes.MapServiceRoute , it should look like 然后,当您执行RouteTable.Routes.MapServiceRoute ,它应该看起来像

 RouteTable.Routes. MapServiceRoute<WebServiceResources, HttpsServiceHostFactory>("ws", configuration); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 提供的URI方案&#39;http&#39;无效; 预期&#39;https&#39; - provided URI scheme'http' is invalid; expected 'https' WCF客户端:提供的URI方案“ http”无效; 预期的“ https” - WCF Client : The provided URI scheme 'http' is invalid; expected 'https' Web服务错误“提供的URI方案&#39;http&#39;无效; 预计&#39;https&#39;。“ - Web Service Error “The provided URI scheme 'http' is invalid; expected 'https'.” wcf client .exception“提供的URI方案&#39;http&#39;无效; 预期的“ https” - wcf client .exception “The provided URI scheme 'http' is invalid; expected 'https” C#提供的URI方案'http'无效;预期'https' - C# The provided URI scheme 'http' is invalid; expected 'https' 提供的 URI 方案“https”无效; 预期&#39;http&#39;。 参数名称:通过 - The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via 提供的URI方案“ http”无效; 预期为“ https”。 参数名称:通过 - The provided URI scheme 'http' is invalid; expected 'https'. Parameter name: via 捕获提供的URI方案“ http”无效; 预期的“ https”错误 - Catch The provided URI scheme 'http' is invalid; expected 'https' error ClientBase 和 https 连接。 提供的 URI 方案“https”无效; 预期&#39;http&#39;。 参数名称:通过 - ClientBase and https connection. The provided URI scheme 'https' is invalid; expected 'http'. Parameter name: via 提供的URI方案“https”无效; 调用Web服务时需要&#39;http&#39; - The provided URI scheme 'https' is invalid; expected 'http' when calling web service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM