我正在本地运行一个连接到外部服务器的Web服务,但我无法访问该服务器。
尽管此Web服务的管理员已经确认测试凭据完全正确,但我仍然不断收到“401:未经授权”的错误。
我需要调整IIS设置吗?
这是错误的屏幕截图。
// Webservice
IdentityService ws = new IdentityService();
// Test Static Credentials
string username = "twfnf";
string password = "testme99";
string domain = "testapps1";
NetworkCredential credentials = new NetworkCredential(username, password, domain);
CredentialCache credCache = new CredentialCache();
credCache.Add(new Uri(ws.Url), "Basic", credentials);
ws.Credentials = credCache;
ws.PreAuthenticate = true;
ws.AuthenticateUser();
IdentityService
是一个 SOAP 风格的 Web 服务(默认情况下类似于 WCF Web 服务),还是旧的 .NET 2.0 ASMX Web 服务? - Sean Hanley