gpt4 book ai didi

asp.net - 尝试从 ASP.NET 调用外部 Web 服务返回 401 - DefaultCredentials 为空

转载 作者:行者123 更新时间:2023-12-02 13:18:32 28 4
gpt4 key购买 nike

失败:

//Note: webserviceProxy inherits from SoapHttpClientProtocol
//App Pool is running as a user with permissions to call the external webservice

var webserviceProxy = new webServiceProxy();

webserviceProxy.PreAuthenticate = true;
webserviceProxy.UseDefaultCredentials = true;

var returnVal = webServiceProxy.DoSomething(); //Fails with 401, webserviceProxy.Credendials shows an empty username, pass, and domain

作品:

//This code works, but I want to assign the current app pool's credentials to the webservice proxy's credentials.  UsingDefaultCredentials doesn't work.  The username, passoword, and domain are always null.

var webserviceProxy = new webServiceProxy();

webserviceProxy.PreAuthenticate = true;
webserviceProxy.Credentials = new NetworkCredential("user", "pass", "domain");

var returnVal = webServiceProxy.DoSomething(); //Fails with 401

如何使用 ASP.NET 应用程序池的身份进行外部 Web 服务调用?似乎没有办法将 System.Security.Principal.WindowsIdentity.GetCurrent() 转换为我可以用于此调用的内容。

谢谢!

最佳答案

关于asp.net - 尝试从 ASP.NET 调用外部 Web 服务返回 401 - DefaultCredentials 为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2740311/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com