[英]Jenkins + Sonarqube - Unhandled Exception: System.Net.WebException: The remote server returned an error: (401) Unauthorized
[英]Webexception:remote server returned an error (401)unauthorized
给予例外
HttpWebResponse webresponse = (HttpWebResponse)webrequest.GetResponse();
这一行。错误信息是
远程服务器返回错误 401 未经授权
它仅在从其他项目解决方案调用 Web 服务时发生...从同一项目解决方案调用服务时不会发生此异常。
我应该怎么做才能删除此异常并从远程服务器获取响应? 请帮助我。
可能的解决方案可以是:
1) 在 web.config 中添加<identity impersonate="true"></identity>
2)如果你有凭据
using (client = new MyWebService())
{
var username = ConfigurationManager.AppSettings["WSUserName"]
var password = ConfigurationManager.AppSettings["WSPassword"]
client.Credentials = new NetworkCredential(username, password);
// .. and the call here ..
}
如果它不能解决您的问题,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.