需要保护我的WCF服务 [英] Need to Secure my WCF services

查看:71
本文介绍了需要保护我的WCF服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好b $ b

我正在开发一个教育项目,为此我使用了WCF服务。 WCF服务工作正常,现在我需要保护它。现在我使用global.asax中的代码来处理我的服务而没有配置END POINT。



Global.asax



Hi
i am developing one education project and for this i used WCF services. WCF services work fine bu t now i need to secure it. Right Now i use code in global.asax to work my services without configure END POINT.

Global.asax

protected void Application_BeginRequest(object sender, EventArgs e)
   {

       HttpContext.Current.Response.AddHeader("Access-Control-Allow-Origin", "*");

       if (HttpContext.Current.Request.HttpMethod == "OPTIONS")
       {
           HttpContext.Current.Response.AddHeader("Cache-Control", "no-cache");

           HttpContext.Current.Response.AddHeader("Access-Control-Allow-Methods", "GET, POST");

           HttpContext.Current.Response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept");

           HttpContext.Current.Response.AddHeader("Access-Control-Max-Age", "1728000");

           HttpContext.Current.Response.End();
       }

   }







web.config






web.config

<service name="restservice.UserType" behaviorConfiguration="ServiceBehaviour">
      <endpoint address="" binding="webHttpBinding" contract="restservice.IUserType" behaviorConfiguration="webHttp"/>
    </service>
    <service name="restservice.User" behaviorConfiguration="ServiceBehaviour">
      <endpoint address="" binding="webHttpBinding" bindingName="StreamedRequestWebBinding" bindingConfiguration="StreamedRequestWebBinding" contract="restservice.IUser" behaviorConfiguration="webHttp"/>
    </service>
    <service name="restservice.Location" behaviorConfiguration="ServiceBehaviour">
      <endpoint address="" binding="webHttpBinding" contract="restservice.ILocation" behaviorConfiguration="webHttp" />
    </service>
    <service name="restservice.BMS" behaviorConfiguration="ServiceBehaviour">
      <endpoint address="" binding="webHttpBinding" contract="restservice.IBMS" behaviorConfiguration="webHttp"/>
    </service>
    <service name="restservice.FriendService" behaviorConfiguration="ServiceBehaviour">
      <endpoint address="" binding="webHttpBinding" contract="restservice.IFriendService" behaviorConfiguration="webHttp"/>
    </service>







i发布了这项服务。任何客户端站点都可以轻松使用我的服务。如何限制IP?

请给出正确的解决方案

先谢谢




i published this services. and any client site can use easily to my services. how to restrict IP?
Please give proper solution
Thanks in Advance

推荐答案

hi
如果您使用的是iis,您可以限制IP访问,启用IP地址和域名限制

erika
hi If you are using iis you can restrict ip access enabling "IP Address and Domain restrictions"
erika


这篇关于需要保护我的WCF服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆