远程服务器返回错误:(401)在.NET远程处理中未经授权

远程服务器返回错误:(401)在.NET远程处理中未经授权,.net,authentication,exception-handling,remoting,http-status-code-401,.net,Authentication,Exception Handling,Remoting,Http Status Code 401,我开发了一个远程服务(在ISS中托管.NET类型)。 IIS配置为使用“集成Windows身份验证” 当我在“localhost”上执行单元测试服务时,它工作得非常好 (下面的代码是我用于测试的代码),但在我将服务部署到测试服务器(位于另一个域中)之后, 它开始抛出“System.Net.WebException:远程服务器返回错误:(401)Unauthorized.”异常 string url = string.Concat(@"http://", serverName, "/", Serv

我开发了一个远程服务(在ISS中托管.NET类型)。 IIS配置为使用“集成Windows身份验证”

当我在“localhost”上执行单元测试服务时,它工作得非常好 (下面的代码是我用于测试的代码),但在我将服务部署到测试服务器(位于另一个域中)之后, 它开始抛出“System.Net.WebException:远程服务器返回错误:(401)Unauthorized.”异常

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代理的配置有关?

您使用的凭据是什么?系统是否使用Windows身份验证?如果是,其他域是否接受来自您域的用户

您可能必须定义域之间的信任关系,或者使用服务器域的不同和适当的凭据登录