请求因 HTTP 状态 401 失败:Access Denied

解决WebService调用401错误
本文介绍了解决客户端调用WebService时遇到401(Access Denied)错误的方法。一是通过配置服务目录允许匿名访问;二是保持IIS匿名访问设置不变的情况下,将DefaultCredentials分配给Web服务客户端代理的Credentials属性。
客户端调用Web Service出现错误:

 

 

1.远程调用时将相应的服务目录配置“允许匿名访问”


2.出于对安全性的考虑,不更改IIS的匿名访问设置可采用以下方法解决问题:
将DefaultCredentials分配给Web服务客户端代理的Credentials属性。
示例:

localhost.Service1 localhostService1 = new WebApplication1.localhost.Service1();
localhostService1.Credentials=System.Net.CredentialCache.DefaultCredentials;


说明:
(1)Credentials:客户端身份验证的安全凭据
(2)System.Net.CredentialCache.DefaultCredentials:应用程序的系统凭据

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Net.WebException: 请求因 HTTP 状态 401 失败:Access Denied。

源错误:



解决方法:
行 13462: 10-30 14:23:40.963614 2405 2405 E perfetto: tats_data_source.cc:268 Failed to open /sys/class/devfreq/ (errno: 13, Permission denied) 行 16165: 10-30 14:23:41.963445 4455 4533 W libc : Access denied finding property "vendor.gsm.serial" 行 16222: 10-30 14:23:42.015218 4455 4533 W libc : Access denied finding property "vendor.gsm.serial" 行 16337: 10-30 14:23:42.074259 4455 10052 W libc : Access denied finding property "vendor.gsm.serial" 行 19065: 10-30 14:23:42.935439 20217 20217 W libc : Access denied finding property "persist.vendor.sys.activitylog" 行 20124: 10-30 14:23:43.328923 20217 20304 E SchedAssist: open sharedFd failed with error=Permission denied 行 20125: 10-30 14:23:43.329035 20217 20304 E SchedAssist: open sharedFd failed with error=Permission denied 行 20127: 10-30 14:23:43.329062 20217 20304 E SchedAssist: open sharedFd failed with error=Permission denied 行 20128: 10-30 14:23:43.329072 20217 20304 E SchedAssist: open sharedFd failed with error=Permission denied 行 20497: 10-30 14:23:43.480338 20328 20328 W libc : Access denied finding property "persist.vendor.sys.activitylog" 行 20782: 10-30 14:23:43.649296 20217 20271 W libc : Access denied finding property "ro.serialno" 行 20786: 10-30 14:23:43.649914 20217 20271 W libc : Access denied finding property "ro.serialno" 行 20835: 10-30 14:23:43.670603 20380 20380 W libc : Access denied finding property "ro.serialno" 行 20854: 10-30 14:23:43.677196 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 21420: 10-30 14:23:43.841572 20217 20295 W libc : Access denied finding property "vendor.boot.vbmeta.device_state" 行 21421: 10-30 14:23:43.841618 20217 20295 W libc : Access denied finding property "ro.vendor.warranty_bit" 行 21423: 10-30 14:23:43.841638 20217 20295 W libc : Access denied finding property "ro.vendor.boot.warranty_bit" 行 21437: 10-30 14:23:43.844405 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 21439: 10-30 14:23:43.845227 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 21458: 10-30 14:23:43.848830 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 21567: 10-30 14:23:43.884732 20217 20295 W libc : Access denied finding property "ro.secure" 行 21568: 10-30 14:23:43.884772 20217 20295 W libc : Access denied finding property "ro.debuggable" 行 21619: 10-30 14:23:43.920794 4696 6233 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:sg.bigo.live:getSubscriberIdForSubscriber:-1 行 22122: 10-30 14:23:44.119837 20328 20464 W libc : Access denied finding property "ro.serialno" 行 22123: 10-30 14:23:44.120671 20328 20464 W libc : Access denied finding property "ro.serialno" 行 22177: 10-30 14:23:44.179626 20514 20514 W libc : Access denied finding property "ro.serialno" 行 22806: 10-30 14:23:44.509862 20328 20476 W libc : Access denied finding property "vendor.boot.vbmeta.device_state" 行 22807: 10-30 14:23:44.509963 20328 20476 W libc : Access denied finding property "ro.vendor.warranty_bit" 行 22808: 10-30 14:23:44.509984 20328 20476 W libc : Access denied finding property "ro.vendor.boot.warranty_bit" 行 22856: 10-30 14:23:44.554277 20328 20476 W libc : Access denied finding property "ro.secure" 行 22857: 10-30 14:23:44.554354 20328 20476 W libc : Access denied finding property "ro.debuggable" 行 22884: 10-30 14:23:44.586780 4696 6233 W TelephonyPermissions: reportAccessDeniedToReadIdentifiers:sg.bigo.live:getSubscriberIdForSubscriber:-1 行 23536: 10-30 14:23:45.244199 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 23809: 10-30 14:23:45.582676 20217 20217 W libc : Access denied finding property "ro.debuggable" 行 26105: 10-30 14:23:46.929048 2496 14600 I AttributionAndPermissionUtils: checkPermission (forDataDelivery 0 startDataDelivery 0): Permission hard denied for client attribution [uid 10370, pid 20217, packageName "<unknown>"] 行 26107: 10-30 14:23:46.930287 20217 20411 W libc : Access denied finding property "vendor.camera.aux.packagelist" 行 26111: 10-30 14:23:46.931919 20217 20411 W libc : Access denied finding property "vendor.camera.aux.packagelist" 行 26114: 10-30 14:23:46.933312 20217 20411 W libc : Access denied finding property "vendor.camera.aux.packagelist" 行 26119: 10-30 14:23:46.938428 20217 20411 W libc : Access denied finding property "vendor.camera.aux.packagelist" 行 26121: 10-30 14:23:46.938976 20217 20411 W libc : Access denied finding property "vendor.camera.aux.packagelist" 行 26334: 10-30 14:23:47.024803 2010 7490 D AudioPolicyManagerExtImpl: checkUllCompatible() denied raw flag on session 241 for performance noise 行 26341: 10-30 14:23:47.025483 2010 7490 D AudioFlinger: AF createTrack_l, skip effectchain::checkOutputFlagCompatibility to avoid fast flag to be denied by global effects, pid 20217, session -1 行 26374: 10-30 14:23:47.029000 2010 2010 W AudioRtBoostThr: type=1400 audit(0.0:1008): avc: denied { getsched } for scontext=u:r:audioserver:s0 tcontext=u:r:untrusted_app:s0:c114,c257,c512,c768 tclass=process permissive=0 行 26412: 10-30 14:23:47.037000 2010 2010 W AudioRtBoostThr: type=1400 audit(0.0:1009): avc: denied { getsched } for scontext=u:r:audioserver:s0 tcontext=u:r:untrusted_app:s0:c114,c257,c512,c768 tclass=process permissive=0 行 26414: 10-30 14:23:47.045432 20217 20411 W libc : Access denied finding property "ro.hardware.chipname" 行 26449: 10-30 14:23:47.057000 2010 2010 W AudioRtBoostThr: type=1400 audit(0.0:1010): avc: denied { getsched } for scontext=u:r:audioserver:s0 tcontext=u:r:untrusted_app:s0:c114,c257,c512,c768 tclass=process permissive=0 行 26588: 10-30 14:23:47.101000 2010 2010 W AudioRtBoostThr: type=1400 audit(0.0:1011): avc: denied { getsched } for scontext=u:r:audioserver:s0 tcontext=u:r:untrusted_app:s0:c114,c257,c512,c768 tclass=process permissive=0 行 29179: 10-30 14:23:48.226797 2496 14600 I AttributionAndPermissionUtils: checkPermission (forDataDelivery 0 startDataDelivery 0): Permission hard denied for client attribution [uid 10370, pid 20217, packageName "<unknown>"]
最新发布
11-08
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值