I have hosted a webservice in my server. I have list of ip(4) from where i will get the request. I don't want others to access my webservice. How do i acheive this? Is it possible through code? Please give a solution.
Aside from the fact that IP-based restrictions are pretty insecure as IP headers are easily forged with the right toys, it is pretty easy.
Method #1: just let IIS handle it by only allowing the specified sites to access your app
Method #2: handle it in the application layer with a custom HTTP module
1. Can be set in IIS if this is running on its on server, virtual server. This would be the best solution as stops hackers accessing near the top of the chain.
2. C# code
<code>
if(Context.Request.UserHostAddress == '192.168.0.0' || Context.Request.UserHostAddress == '192.168.0.1')
{
// Code for webservice
}
else
{
// Your not allowed
Context.Response.Status = 403; // Forbidden
}
</code>
3.
Please give a solution.
Many people in many cultures will find it offensive if you tell them what to do, espcially when your the one asking for help. Thier attitude will be, if you want them to help you, you get it in any form they see fit. Hope this helps you for the future.
Last edited by SirKilljoy; Apr 6, 2009 at 07:55.
Reason: Staus = 403 not 404, btw I didn't see wwb_99 post when I replied. So don't wish to sound like I disagree with him in anyway
Bookmarks