Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 418021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:38:17+00:00 2026-05-12T18:38:17+00:00

I have a C# .net webservice that I need to restrict access to. I

  • 0

I have a C# .net webservice that I need to restrict access to. I already require my consumers to use a username and password to call the service. But, is there a way to restrict access to the actual asmx page and the WSDL? I would need to restrict access to the webservice by username/password and IP address. If a user did not have the correct credentials, I would not want them to know what webmethods exist in the webservice.

Can this be done though IIS? I know that I can restrict IP addresses through IIS, but can I also use usernames/passwords?

Is there any other way to do this outside of IIS, maybe using C#.net?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T18:38:17+00:00Added an answer on May 12, 2026 at 6:38 pm

    Well, since it’s ASMX you have the entire ASP.NET runtime stack at your disposal.

    Step #1 – managing the resource through .config

    Apply a <location> tag for the resources you want secured. Assuming it’s a single ASMX file you can simply do the following in your web.config:

    <location path="MyWebService.asmx">
        <system.web>
            <!-- resource specific options will go here -->
        </system.web>
    </location>
    

    Step #2 – authenticating your users

    You need to decide how you’re actually going to authenticate users. There are several ways to do this and several authentication standards you could leverage. You need to pick the approach that’s the right fit for you.

    If you’re on an intranet and are using Windows authentication I would highly suggest leveraging that because it’s truly the simplest option to get setup. However, if your services are being accessed over the internet then Windows authenticatio is not really an option and you need to choose from a web standard. The simplest of those is Basic Authentication, but you should only use this over SSL since the username/password are not encrypted (only base64 encoded). The next step up from that is Digest authentication which doesn’t require SSL because the username/password are sent using an MD5 hash. For the ultimate you can go with SSL v3 where you issue a specific client certificate to each user of your API.

    Now, which option you select for security dictates what else needs to be done. If you choose Windows security, it’s as easy as adding the following element to the <system.web> element we started with in Step #1:

    <authentication mode="Windows" />
    

    The remainder of the security protocols are going to require a little more work. ASP.NET doesn’t provide intrinsic support for Basic, Digest or SSL v3. Technically you can leverage IIS to do this type of authentication for you, but it’s always going to map to a Windows user. If that’s an option for you, then simply leave the <authentication mode="Windows" /> element and configure IIS accordingly. If, however, that is not an option, either because you simply have no control over IIS/ActiveDirectory or you need to authenticate against a custom user database, then that means that you need to hook up a custom HttpModule to provide support for these security protocols.

    Step #3 – securing the resource

    The simplest approach to securing the resource is to basically say: “don’t let anyone who hasn’t successfully authenticated in some way into this resource”. This is done using the following authorization configuration:

    <authorization>
        <deny users="?" />
    </authorization>
    

    If you wanted to only allow certain users you could change to do the following instead:

    <authorization>
        <deny users="*" />
        <allow users="jdoe, msmith" />
    </authorization>
    

    Another approach is to define roles (groups) and simply lock the resource down to a special role which you put the users who you want to access the resource into.

    <authorization>
        <deny users="*" />
        <allow roles="My Service Users" />
    </authorization>
    

    This maps well to Windows authentication because you can just setup a Windows group and let your MIS team manage which users are in that group using ActiveDirectory. However, the feature also works just fine for non-Windows authentication assuming the security implementation you’ve used exposes roles via its IPrincipal implementation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a webservice in .NET and I need to call that webservice with
I have a .Net XML webservice that I need a simple Sinatra app to
I have an ASP.NET web service that I can access via a windows program
we have a server and i need a ASP.NET webservice to access to an
I have a .net ASMX webservice that I'm consuming using the ksoap2 library. In
I have an ASP.NET WebService that returns an object of List public class Students
I have an ASP.NET WebService that supports standard WSDL based SOAP calls and a
I have an ASP.NET website that is contacting a webservice. Everything works fine connecting
i have an ASP.NET web service that returning a custom entity object (Staff): [WebMethod]
I have an ASP.net web service that I'm using for a web application which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.