IP Address Restriction for a Web-Service in ASP.NET !

Posted on 2006-05-07
Last Modified: 2008-03-10


I want to know how we can do IP Address Restriction for a Web-Service in ASP.NET. Can you provide the sample Server and Client applications for this ! Can we do by using programatically ?

Question by:kishore_peddi
    LVL 6

    Assisted Solution

    LVL 15

    Accepted Solution

    Maybe a bit more detail?

    If you are trying to secure it by declining non compliant IP addresses I don't think it is the best way since these can be faked.

    Using junglerover77's answer you would basically just have the following

    public string TestMethod()
        if( Context.ApplicationInstance.Request.UserHostAddress.ToString() != "" )
            return null;
             //Process request
    LVL 6

    Assisted Solution

    It's in IIS settings, exactly as any webapplication.
    I'm not sure about doing it programmatically.

    see this greate example

    // using
    is not as safe as using IIS, but if you want more security, you can use it as second gate.
    See the link above and note how securing IIS and webserivces will make better security.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    I have developed many web applications with asp & and to add and use a dropdownlist was always a very simple task, but with the new, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    how to add IIS SMTP to handle application/Scanner relays into office 365.

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now