none
How to force WCF RESTful service to use anonymous authentication RRS feed

  • Question

  • Both Anonymous Authentication and Windows Authentication are enabled on my IIS. Some WCF services on my IIS must use Windows Authentication.

    Recently I added a WCF RESTful service to my IIS, and I want to use Anonymous Authentication for it. However no matter how I change the settings in web.config file, I find the WCF RESTful service always uses Windows Authentication. How to force the WCF RESTful service to use anonymous authentication?

    Friday, June 1, 2018 9:35 PM

All replies

  • Don't you have to go to IIS and for the Web application  and set authentication to use?
    Saturday, June 2, 2018 4:00 AM
  • Hi Pierreshiny,

    >>However no matter how I change the settings in web.config file, I find the WCF RESTful service always uses Windows Authentication.

    What do you mean by this? Could you share us a simple project which could reproduce your issue?

    I made a test with steps below, it uses anonymous authentication correctly.

    1. Create a WCF Rest Service

    2. Host it in IIS

    3. Enable Anonymous authentication and Windows Authentication for Default web site

    4. Access WCF Rest Service, there is no error.

    5. Check the current identity, it is null which mean Anonymous.

            [WebGet]
            public string GetData(int value)
            {
                var user = HttpContext.Current.User.Identity.Name;
                return string.Format("You entered: {0}", value);
            }
    

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, June 4, 2018 1:58 AM