【问题标题】:Disable http protocl for wcf rest asp.net mvc禁用 wcf rest asp.net mvc 的 http 协议
【发布时间】:2015-01-20 12:27:41
【问题描述】:

我正在使用 asp.net mvc 和 wcf rest。 我在 asp.net mvc 中托管了休息服务。 和配置文件看起来像这样

 <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
    <standardEndpoints>
      <webHttpEndpoint>
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="false"/>
      </webHttpEndpoint>


    </standardEndpoints>
  </system.serviceModel>

和 global.ascx

   protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteTable.Routes.Add(new ServiceRoute("Rest", new WebServiceHostFactory(), typeof(Rest)));
            RegisterRoutes(RouteTable.Routes);
        }

可以使用 http 或 https 访问我的 asp.net Web 应用程序。 但我想仅在 https 中使用 rest api 如何禁用 wcf rest api 的 http 协议。 我没有 .svc 文件。

【问题讨论】:

    标签: c# asp.net asp.net-mvc wcf rest


    【解决方案1】:

    也许你可以使用以下配置来做到这一点

    <bindings>
      <webHttpBinding>
        <binding>
          <security mode="Transport" />
        </binding>
      </webHttpBinding>
    </bindings>
    <standardEndpoints>
      <webHttpEndpoint>
        <!-- 
            Configure the WCF REST service base address via the global.asax.cs file and the default endpoint 
            via the attributes on the <standardEndpoint> element below
        -->
        <standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true">
          <security mode="Transport" >
    
          </security>
        </standardEndpoint>
      </webHttpEndpoint>
    </standardEndpoints> 
    

    【讨论】:

      【解决方案2】:

      this 有帮助吗?您没有在问题中列出绑定设置,但通常在这里配置。

      <security mode="Transport"/> 
      

      是所有这一切的关键部分。

      【讨论】:

      • 因为我没有..它是在带有asp.net mvc的iis中运行
      • 我认为你可能仍然需要一个绑定部分,重要的是你设置了安全模式=“传输”
      • 我添加了绑定,但标准端点不支持绑定配置它显示错误
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-12-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-18
      相关资源
      最近更新 更多