远程服务器返回错误:(401) .NET Remoting 中未经授权
我开发了一个远程服务(在 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.
可能是什么问题?与域相关吗?可能与默认网络代理的配置有关?
I developed a remoting service (hosting .NET type in the ISS).
IIS is configured to use "Integrated Windows Auth".
It works perfectly when I execute unit test the service on the "localhost"
(the code below is the code I use for testing), but after I have deployed a service to the test server (which in another another domain),
it started throwing a "System.Net.WebException: The remote server returned an error: (401) Unauthorized." exception.
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.
What might be the issue? Is it domain related? May be it has something to do with a configuration of the default web proxy?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您使用什么凭证?系统是否使用Windows身份验证?如果是,其他域是否接受来自您域的用户?
您可能必须定义域之间的信任关系,或者使用服务器域的不同且适当的凭据登录。
What credentials are you using? Is the system using Windows authentication? If so, does the other domain accept users from your domain?
You may have to define a trust relationship between domains, or log in with different and appropriate credentials for the server's domain.