当前正在开发一个连接到 Azure 移动服务的应用,并且需要 Microsoft 帐户进行身份验证。
我一直在遵循本指南: http://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-universal-dotnet-get-started-users/不幸的是,我遇到了这个错误:仅允许使用 https 方案。并且我不完全确定如何修复它。
错误截图:/image/hod9i.png
我的代码如下,来自上面列出的指南。
private async void executiveLoginBtn_Click(object sender, Windows.UI.Xaml.RoutedEventArgs e)
{
await AuthenticateAsync();
}
// Define a member variable for storing the signed-in user.
private MobileServiceUser user;
// Define a method that performs the authentication process
// using a Facebook sign-in.
private async System.Threading.Tasks.Task AuthenticateAsync()
{
while (user == null)
{
string message;
try
{
// Change 'MobileService' to the name of your MobileServiceClient instance.
// Sign-in using Facebook authentication.
user = await App.MobileService
.LoginAsync(MobileServiceAuthenticationProvider.MicrosoftAccount);
message =
string.Format("You are now signed in - {0}", user.UserId);
}
catch (InvalidOperationException)
{
message = "You must log in. Login Required";
}
var dialog = new MessageDialog(message);
dialog.Commands.Add(new UICommand("OK"));
await dialog.ShowAsync();
}
}
该错误还显示“WinRT 信息:URI 方案不是 https” - 那么在向 Azure 移动服务进行身份验证时,我该如何制作 URI 方案 https 或以其他方式修复此错误?
最佳答案
1) 在解决方案资源管理器中选择本地 MobileService 项目。
2) 在“属性”窗口中,将“SSL Enabled”更改为“True”。
3) 记下 SSL URL 并使用该地址初始化客户端应用程序中的 MobileServiceClient 对象。
关于c# - 身份验证 - 仅允许 HTTPS 方案,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27141441/