WebServiceHostFactory and IIS authentication

前端 未结 4 1993
遥遥无期
遥遥无期 2021-02-05 21:19

I encounter a problem with using the WebServiceHostFactory in IIS.

\"IIS specified authentication schemes \'IntegratedWindowsAuthentication, Anonymous\', but the binding

4条回答
  •  [愿得一人]
    2021-02-05 21:32

    This is what worked for me. Adding a dummy endpoint early on (before the service host is opened) as shown below seems to have done the trick. (This MSDN article hinted at this http://msdn.microsoft.com/en-us/library/bb412178.aspx.)

    public class MyWebServiceHost : WebServiceHost
    {
        public MyWebServiceHost (Type serviceType, params Uri[] baseAddresses) : base(serviceType, baseAddresses)
        {
            // Inserting this dummy endpoint config seemingly does the trick:
            AddServiceEndpoint(typeof(IMyContract), new WebHttpBinding(), string.Empty);
        }
    
        protected override void ApplyConfiguration()
        {
            // Typical programmatic configuration here per:
            // http://msdn.microsoft.com/en-us/library/aa395224.aspx
        }
    }
    

    I'm guessing this prevents WebServiceHost from creating a default endpoint, and thus shutting down a bunch of functionality.

提交回复
热议问题