在没有Window身份验证的情况下保护Wcf json Web服务

时间:2015-09-30 21:18:22

标签: c# json wcf

我想要保护网络服务。我必须避免窗口身份验证,因为托管公司会给我带来一些问题

怎么可能?如果要在web.config文件中配置用户/密码(或只是密码。它应该用于该Web服务),我是最好的选择。

我想我可以添加一个特殊参数但看起来很难看

我的配置是:

  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="false" multipleSiteBindingsEnabled="true"/>
    <services>
      <service name="ct.WebServices.WsCT">
        <endpoint address="" behaviorConfiguration="ct.WebServices.Service1AspNetAjaxBehavior" binding="webHttpBinding" contract="ct.WebServices.WsCT"/>
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="ct.WebServices.Service1AspNetAjaxBehavior">
          <webHttp faultExceptionEnabled="true"/>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <webHttpBinding>
        <binding>
          <readerQuotas maxStringContentLength="1000000"/>
        </binding>
      </webHttpBinding>
    </bindings>
  </system.serviceModel>

Android设备使用网络服务

代码是:

namespace ct.WebServices
{
    [ServiceContract(Namespace = "")]
    [ServiceBehavior(IncludeExceptionDetailInFaults = true)]
    public class WsCT
    {
        [OperationContract]
        [WebGet(ResponseFormat = WebMessageFormat.Json, UriTemplate = "/modif")]
        public IList<Ws.Modification> GetModifs() { return null; }
    }
}

0 个答案:

没有答案