Mono \ Xamarin是否支持Basic身份验证?

时间:2014-11-20 19:08:45

标签: c# mono

我尝试使用Xamarin.Android运行此代码,但它落在最后一行(System.Net.WebException:处理Web请求时出错:状态代码401(未授权)):

var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var endPointUri = new Uri(@"http://192.168.1.241/edo/Euphrates.svc/ILogonService-Basic");
var factory = new ChannelFactory<ILogonService>(binding, new EndpointAddress(endPointUri));
factory.Credentials.UserName.UserName = "test";
factory.Credentials.UserName.Password = "test";
ILogonService service = factory.CreateChannel();
Console.WriteLine(service.Logon("test"));

在Windows控制台应用程序上,一切都运行良好。

1 个答案:

答案 0 :(得分:0)

您可以在Xamarin的网址中使用基本身份验证:

https://username:password@www.example.com/webcallback?foo=bar