Take the 2-minute tour ×

I have one asp.net web service (asmx) in separate project that is hosted on windows server having other asp.net web applications running on it. How can I restrict asp.net web service to be accessed by single IP address? I want that my web service must be accessed by one IP configured by me. If requests comes from any other IP, it must not reach to my web service and discarded by windows firewall itself. I know that this is something to do with windows firewall.

I did it for SQL Server previously, but I don't know how to configure single asp.net web service project to do so.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

Unless your web service is running in a separate IIS instance on a different port than the rest of your asp.net sites, there's no way to do what you're asking with the firewall. The firewall can only block things by port, not URL.

So you have two choices.

  1. Move the web service to its own IIS instance running on a non-standard port (81, 8080, etc). Then add your firewall rule that restricts incoming traffic to that port for your designated IP address.

  2. Add code to your web service so that it is actually responsible for rejecting requests that come in from invalid IP addresses. It should be easy enough to do with the session/request objects you have access to.

share|improve this answer
Thank you. I will first go with the first option and then second. I will let you know the outcome. –  Suresh Agrawal Mar 12 '11 at 19:05
Do you mean that I have to run it on separate IIS application pool? Can you please tell me how to move web service project to separate IIS instance on a non-standard prot and configure firewall rule. I can't find any option for this. –  Suresh Agrawal Mar 14 '11 at 16:55
I am able to change the port binding for whole website. How can I change it for one virtual application? –  Suresh Agrawal Mar 14 '11 at 17:27
From the IIS Manager in the Sites section, Add New Site. –  Ryan Bolger Mar 14 '11 at 19:56

Your Answer


