简体   繁体   English

即使虚拟目录允许匿名访问,Web 服务也会出现“HTTP 状态 401:访问被拒绝”错误

[英]"HTTP status 401: Access Denied" error for web service even when the virtual directory allows Anonymous access

i have a web service hosted on another server with the Anonymous Access CheckBox in IIS is already checked.我在另一台服务器上托管了一个 Web 服务,IIS 中的匿名访问复选框已被选中。 when my local web application is trying to access the web service, i still get the "The request failed with HTTP status 401: Access Denied."当我的本地 Web 应用程序尝试访问 Web 服务时,我仍然收到“请求失败,HTTP 状态 401:访问被拒绝”。 error.错误。 my web application is calling the web service like the following:我的 Web 应用程序正在调用 Web 服务,如下所示:

MyObject.WebService ws = new MyObject.WebService (); MyObject.WebService ws = new MyObject.WebService (); ws.Retrieve(someParams); ws.Retrieve(someParams);

what am i missing here?我在这里想念什么?

Here is a good reference on diagnosing 401 errors. 是诊断 401 错误的一个很好的参考。

From that, one place to start is looking at the credentials you configure for the anonymous user.从那开始,一个地方是查看您为匿名用户配置的凭据。 If they are incorrect (if perhaps the user password was changed elsewhere) you will get an HTTP 401.如果它们不正确(如果用户密码可能在其他地方更改),您将收到 HTTP 401。

Make sure your directory permissions are also set to allow everyone read access.确保您的目录权限也设置为允许所有人读取访问权限。 A lot of times doing local dev work I will forgot that the directory being accessed has a seperate set of permissions that need to be altered.很多时候做本地开发工作我会忘记正在访问的目录有一组单独的权限需要更改。

Cheers!干杯!

Check this http://www.c-sharpcorner.com/UploadFile/mahesh/40107282006095201AM/401.aspx .检查这个http://www.c-sharpcorner.com/UploadFile/mahesh/40107282006095201AM/401.aspx

//Assigning DefaultCredentials to the Credentials property //of the Web service client proxy (myProxy). myProxy.Credentials= System.Net.CredentialCache.DefaultCredentials;

This code worked for me.这段代码对我有用。

have you try un selecting the allow iis to control password some times that get out of sink.你有没有尝试取消选择允许 iis 控制密码,有时会离开接收器。

try the site and it may work.尝试该站点,它可能会起作用。 you sould be able to reenable control after that在那之后你就可以重新启用控制了

Try the following (note the PreAuthenticate thingy):尝试以下操作(注意 PreAuthenticate thingy):

MyObject.WebService ws = new MyObject.WebService(); 
ws.PreAuthenticate = true;
response = ws.Retrieve(someParams);

For more detailed explanation why this may work you can reference following answer here http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/3ae9753d-2d97-45b9-9ba2-6d551fe60a48/ .有关为什么这可能有效的更详细说明,您可以在此处参考以下答案http://social.msdn.microsoft.com/Forums/en-US/asmxandxml/thread/3ae9753d-2d97-45b9-9ba2-6d551fe60a48/

I think what might be happening is that you are getting a 401 - permission denied but as to whom the permission is denied to is unclear.我认为可能发生的情况是您收到了 401 - 权限被拒绝,但权限被拒绝的对象尚不清楚。 I am guessing at this point you have checked the NTFS permissions on the machine, and have confirmed that you do have access.我猜此时您已经检查了机器上的 NTFS 权限,并确认您确实具有访问权限。

Next I would look at what account the application pool uses.接下来,我将查看应用程序池使用的帐户。 If it is the default setup, it will probably be the NT Network Service Account.如果它是默认设置,它可能是 NT 网络服务帐户。 If that is the case, confirm that the account does have access to the application directory.如果是这种情况,请确认该帐户确实有权访问应用程序目录。 If that is also the case it might perhaps be a COM+ security setting.如果也是这种情况,它可能是 COM+ 安全设置。 By default your network service account does not have permission to remotely launch components.默认情况下,您的网络服务帐户无权远程启动组件。 If this is the case you will be seeing errors in the system and security log that will say things link, "Unable to launch component "如果是这种情况,您将在系统和安全日志中看到错误链接,“无法启动组件”

Looking at the IIS log files and the system and security event logs on the iis server often yield more clues.查看 IIS 日志文件以及 iis 服务器上的系统和安全事件日志通常会产生更多线索。

Hope it helps Best Regards Rihan Meij希望它有助于最好的问候 Rihan Meij

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 请求失败,HTTP 状态为 401:已授权从 C# asp.net 访问 sharepoint Web 服务 - The request failed with HTTP status 401: authorized for access sharepoint web service from C# asp.net 拒绝访问虚拟目录文件夹 - Access denied to virtual directory folder Web服务访问被拒绝 - Web Service Access Denied 当我尝试使用控制台应用程序添加新的虚拟目录时,访问被拒绝错误 - Access Denied Error When i try to add New Virtual Directory using Console Application 重命名目录时,错误访问路径被拒绝 - Error Access to the path is denied when Rename a Directory 错误 5:启动 Windows 服务时拒绝访问 - Error 5 : Access Denied when starting windows service WCF服务使用Active Directory授权-访问被拒绝错误 - WCF Service Authorizing with Active Directory - Access Denied Error 当我调用ASMX Web服务时访问被拒绝 - Access is denied when I call ASMX web service 请求失败,HTTP 状态为 401:调用 Web 服务时未经授权 - The request failed with HTTP status 401: Unauthorized while calling web service WCF REST服务可在本地正常运行,在远程服务器上显示未授权(401)错误,而该服务具有匿名访问权限 - WCF REST Service works fine on local , gives Unauthorized (401) error on Remote server whereas the service has Anonymous access
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM