在localhost ASP.NET MVC微软Live帐户验证 [英] ASP.NET MVC Microsoft Live Account Authentication on Localhost

查看:343
本文介绍了在localhost ASP.NET MVC微软Live帐户验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个空白的新ASP.NET MVC的网站。

I have created a blank, new ASP.NET MVC site.

我已经建立了一个应用程序的端点在 https://account.live.com/developers/如下:

I have set up an application endpoint at https://account.live.com/developers/ as follows:

API设置: http://i.imgur.com/bIoV3x9.png

API Settings: http://i.imgur.com/bIoV3x9.png

应用程序设置和code-背后: http://i.imgur.com/P3KFyhV。 PNG

App Settings and Code-Behind: http://i.imgur.com/P3KFyhV.png

我曾尝试推出我的网站,连接到 https://开头本地主机:44300 / ,点击登录,然后在微软,我得到一个网页,说以下内容:

I have tried launching my site, connecting to https://localhost:44300/, clicking "Log in", then "Microsoft" and I get a page that says the following:

Microsoft帐户

Microsoft account

我们无法完成您的请求。

We're unable to complete your request

Microsoft帐户遇到技术问题。请稍后再试。

Microsoft account is experiencing technical problems. Please try again later.

但我重定向的URL是:

But the URL it redirects me to is:

<一个href=\"https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20\" rel=\"nofollow\">https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20'redirect_uri'%20is%20not%20valid.%20The%20expected%20value%20is%20'https://login.live.com/oauth20_desktop.srf'%20or%20a%20URL%20which%20matches%20the%20redirect%20URI%20registered%20for%20this%20client%20application

https://login.live.com/err.srf?lc=1033#error=invalid_request&error_description=The%20provided%20value%20for%20the%20input%20parameter%20'redirect_uri'%20is%20not%20valid.%20The%20expected%20value%20is%20'https://login.live.com/oauth20_desktop.srf'%20or%20a%20URL%20which%20matches%20the%20redirect%20URI%20registered%20for%20this%20client%20application

我相信REDIRECT_URI无效。期望值是一些URI来oauth20_desktop.srf。我不知道世界上正在发生的事情/是什么问题。任何人都可以提供一些线索,以什么我必须做测试Microsoft帐户登录到我的本地运行MVC的网站?

I am to believe that the redirect_uri is not valid. The expected value is some URI to oauth20_desktop.srf. I don't know what in the world is going on/what the problem is. Can anyone shed some light as to what I must do to test Microsoft Account logins to my localhost-running MVC site?

推荐答案

您的研究结果是正确的,微软不允许localhost作为 REDIRECT_URI ,它是在解释 ASP.NET之证件 ...

Your findings are correct, Microsoft doesn't allow for localhost as redirect_uri and it is explain in the ASP.NET Documentations...

在注册你的网站与Facebook,可以为网站提供域名本地主机和HTTP://本地主机/的URL,如下图所示。使用localhost大多数供应商的工作,但目前没有与Microsoft提供商合作。对于微软供应商,你必须包含一个有效的网站的网址。

When registering your site with Facebook, you can provide "localhost" for the site domain and "http ://localhost/" for the URL, as shown in the image below. Using localhost works with most providers, but currently does not work with the Microsoft provider. For the Microsoft provider, you must include a valid web site URL.

如果你想获得它的工作,你需要建立一个IIS站点自定义主机头,这将要求您修改hosts文件在你的机器......假设你当然在Windows机器上开发

If you want to get it working you will need to set up an IIS site with custom host headers, this will require you to modify the hosts files in your machine...assuming you are developing on a Windows machine of course


  1. 打开IIS管理控制台,并创建一个新的网站

  2. 在下面输入站点名称,应用程序池,物理路径和最重要的主机头....见截图


  1. 单击OK,创建网站并确保这两个站点和应用程序池正在运行

  2. 在运行命令工具中输入以下系统路径的%SystemRoot%\\ SYSTEM32 \\ drivers \\ etc下来打开该主机文件所在的路径...通常 C:\\ WINDOWS \\ SYSTEM32 \\ drivers \\ etc下

  3. 打开hosts文件,管理员,并添加符合您设置主机头一个条目...

  1. Click OK, to create the site and then make sure both the site and the app pool are running
  2. Enter the following system path in the "Run command" utility %SystemRoot%\system32\drivers\etc to open the path where the hosts file is located...usually C:\Windows\system32\drivers\etc
  3. Open the hosts file as Administrator and add an entry that matches your set up host headers...

127.0.0.1 www.testsite.com

127.0.0.1 www.testsite.com

保存后,您可以打开一个浏览器窗口来测试 http://www.testsite.com

Once saved you can open a browser window to test the set up by type in http://www.testsite.com

这篇关于在localhost ASP.NET MVC微软Live帐户验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆