当我尝试访问计算机本地IIS中站点上托管的HTTP REST API时,收到以下错误消息:
HTTP请求未经授权使用客户端身份验证方案' Anonymous'。从服务器收到的身份验证标题是''"
在站点的IIS身份验证设置中启用匿名身份验证,并将匿名用户的身份设置为IUSR角色的身份。 IUSR角色对与我的IIS站点关联的基础虚拟目录具有读取权限,我还尝试对基础连接虚拟目录进行“Everyone”完全控制(参见下文)。虚拟目录和IIS站点都应具有足够的匿名访问身份验证。 Project Properties - Security - Permissions
此Web项目中使用的完全相同的代码在另一台计算机上运行完全正常,因此我不认为问题出在代码中。
Stack Trace(片段):
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"An exception was thrown while invoking the constructor 'Void .ctor(PIM.App.Infrastructure.Setttings.ISettingsProvider)' on type 'ServiceFactory'. ---> The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''. (See inner exception for details.)","ExceptionType":"Autofac.Core.DependencyResolutionException","StackTrace":"
at Autofac.Core.Activators.Reflection.ConstructorParameterBinding.Instantiate()\r\n
at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)\r\n
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)","InnerException":{"Message":"An error has occurred.","ExceptionMessage":"The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was ''.","ExceptionType":"System.ServiceModel.Security.MessageSecurityException","StackTrace":"\r\nServer stack trace: \r\n
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication(HttpWebRequest request, HttpWebResponse response, WebException responseException, HttpChannelFactory`1 factory)\r\n
at System.ServiceModel.Channels.HttpChannelUtilities.ValidateRequestReplyResponse(HttpWebRequest request, HttpWebResponse response, HttpChannelFactory`1 factory, WebException responseException, ChannelBinding channelBinding)\r\n