【发布时间】:2009-08-27 00:31:15
【问题描述】:
我开发了一个远程服务(在 ISS 中托管 .NET 类型)。 IIS 配置为使用“集成 Windows 身份验证”。
当我在“localhost”上执行单元测试服务时,它工作得很好 (下面的代码是我用于测试的代码),但是在我将服务部署到测试服务器(在另一个域中)之后, 它开始抛出“System.Net.WebException:远程服务器返回错误:(401)未经授权。”例外。
string url = string.Concat(@"http://", serverName, "/", ServiceName);
IDictionary props = new Hashtable();
props["useDefaultCredentials"] = true;
props["useAuthenticatedConnectionSharing"] = true;
BinaryServerFormatterSinkProvider srv = new BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider clnt = new BinaryClientFormatterSinkProvider();
this.channel = new HttpChannel(props, clnt, srv);
ChannelServices.RegisterChannel(this.channel, false);
IMyService service = Activator.GetObject(typeof(IMyService), url) as IMyService;
service.GetData();// this error returns "System.Net.WebException: The remote server returned an error: (401) Unauthorized." exception.
可能是什么问题?它与域有关吗?可能与默认 Web 代理的配置有关?
【问题讨论】:
标签: .net authentication exception-handling remoting http-status-code-401