【问题标题】:configuring a REST wcf with anonymous auth使用匿名身份验证配置 REST wcf
【发布时间】:2015-07-08 09:46:38
【问题描述】:

我遇到了一个关于以 JSON 格式与网站的某些客户端部分通信的 Web 服务的问题 网络服务在网站解决方案中,并在 aspx 页面(网络表单)中使用 VB

我的网络配置是:

<?xml version="1.0"?>
<configuration>
  <system.serviceModel>
    <bindings>

      <webHttpBinding>

        <binding name="Binding1">

          <security  mode="None">
            <transport  clientCredentialType="None" />
          </security>

        </binding>
      </webHttpBinding>
    </bindings>
    <behaviors>
      <serviceBehaviors>
        <behavior name="ServiceBehavior">
          <serviceMetadata httpGetEnabled="true"/>
          <serviceDebug includeExceptionDetailInFaults="true"/>
          </behavior>
        </serviceBehaviors>
      <endpointBehaviors>
        <behavior name="ServiceAspNetAjaxBehavior">
          <enableWebScript/>
          </behavior>
        </endpointBehaviors>
    </behaviors>
    <!--<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>-->
    <services>
      <service name="Z60MRTR002.FrmCommandeAction" behaviorConfiguration="ServiceBehavior">
        <endpoint address="" binding="webHttpBinding" bindingConfiguration="Binding1" contract="Z60MRTR002.FrmCommandeAction" behaviorConfiguration="ServiceAspNetAjaxBehavior" ></endpoint>
          <!--<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />-->
      </service>
    </services>
  </system.serviceModel>

  <system.web>
    <compilation defaultLanguage="vb" debug="true" targetFramework="4.0"/>
    <customErrors mode="Off"/>
    <authentication mode="Windows"/>
    <authorization>
        <allow users="*"/>
    </authorization>

    <sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" cookieless="false" timeout="20"/>

    <globalization requestEncoding="utf-8" responseEncoding="utf-8"/>
    <pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
  </system.web>
  <appSettings>
            <!-- SOME SETTINGS -->
  </appSettings>
</configuration>

我在 IIS 服务器上激活了匿名身份验证。

它在 IISExpress(local) 上运行良好,但在我的生产服务器 (iis6.0) 上运行良好,求助!

错误是:

[NotSupportedException: Les paramètres de sécurité pour ce service requièrent l'authentification 'Anonymous', mais elle n'est pas activée pour l'application IIS qui heberge ce service。]

英文:此服务的安全参数需要“匿名”身份验证,但它并未针对托管 IIS 应用程序激活

编辑: 我将 wcf 复制并粘贴到一个新的 wcf 项目中,然后在服务器上发布它,确保启用了匿名身份验证。它告诉我身份验证未激活。

按照这个: https://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/f594e137-e2da-4b22-ab58-f8edba938802.mspx?mfr=true

如果您需要更多信息,请询问我。 谢谢!

【问题讨论】:

    标签: asp.net vb.net wcf iis web-config


    【解决方案1】:

    确保在 IIS 中启用匿名身份验证,如下所示: https://technet.microsoft.com/en-us/library/cc731244%28v=ws.10%29.aspx

    【讨论】:

    • 它是为整个网站激活的,如代码中所述。我想知道,网络服务“在”网站中这一事实是否会阻碍匿名用户的访问?
    • 也许我应该重命名这个问题,因为它看起来像是身份验证问题,不是吗?
    【解决方案2】:

    我发现了我的错误,它离网络配置和服务器配置都不远。我实际上有一个名为 HttpContext.Current.User ...

    的子函数

    即使已激活,服务器也会返回错误: 所以对于任何激活匿名身份验证但仍然收到错误的人,您可能需要仔细检查您的代码 :)

    我仍然不确定为什么它在 iisExpress 上工作。也许它正在调试的事实允许 iisE 访问 HTTPcontext。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-04-14
      • 2010-11-04
      • 1970-01-01
      • 2019-10-31
      • 2011-03-27
      • 2012-02-17
      相关资源
      最近更新 更多