Click here to Skip to main content
16,015,531 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

C#
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

XML
<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 published this services. and any client site can use easily to my services. how to restrict IP?
Please give proper solution
Thanks in Advance
Posted
Updated 24-Mar-14 21:10pm
v2

1 solution

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

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900