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

发布于 2024-08-02 20:28:19 字数 954 浏览 6 评论 0原文

我开发了一个远程服务(在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

时光匆匆的小流年 2024-08-09 20:28:19

您使用什么凭证?系统是否使用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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文