【问题标题】:The remote server returned an error: (401) Unauthorized in .NET Remoting远程服务器返回错误:(401) Unauthorized in .NET Remoting
【发布时间】: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


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2013-03-24
      • 2014-12-26
      • 1970-01-01
      • 1970-01-01
      • 2011-01-03
      • 1970-01-01
      相关资源
      最近更新 更多