Azure B2C GetOwinContext().Authentication.Challenge使用问号而不是And符号创建错误的url [英] Azure B2C GetOwinContext().Authentication.Challenge creates wrong url with Question mark instead of And sign

查看:90
本文介绍了Azure B2C GetOwinContext().Authentication.Challenge使用问号而不是And符号创建错误的url的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Azure B2C,并且正在 https://docs.microsoft.com/zh-cn/azure/active-directory/develop/active-directory-devquickstarts-webapp-dotnet 作为启动指南.我设法通过用我的客户端ID,租户ID等替换配置条目来很好地运行此示例.但是,当我尝试将Azure B2C身份验证添加到当前Web应用程序(Asp.NET MVC dot net 4.5)时,它表现得非常出色.怪异的方式.当我按登录时,它会将我重定向到一个与工作示例中稍有不同的URL.它用问号/authorize?p = b2c_1_signin ***?*** client_id

I am using Azure B2C and I am using the project at https://docs.microsoft.com/en-us/azure/active-directory/develop/active-directory-devquickstarts-webapp-dotnet as startup guide. I manage to run this sample fine by replacing the config entries with my client ID, tenant ID, etc. However when I try to add Azure B2C authentication to my current web app (Asp.NET MVC dot net 4.5) it behaves in a very weird way. When I press log in it redirects me to a slightly different url than it does in the working sample. It replaces the And sign after the policy with a question mark /authorize?p=b2c_1_signin***?***client_id

这是在Azure B2C门户窗口中显示策略URL的方式: https://login.microsoftonline.com/XXX.onmicrosoft.com/oauth2/v2.0/authorize?p= B2C_1_SignIn& client_id = XXXX& nonce = defaultNonce& redirect_uri = https%3A%2F%2Flocalhost%3A44316%2F& scope = openid& response_type = id_token& prompt =登录

This is how the policy url is showing in the Azure B2C portal window: https://login.microsoftonline.com/XXX.onmicrosoft.com/oauth2/v2.0/authorize?p=B2C_1_SignIn&client_id=XXXX&nonce=defaultNonce&redirect_uri=https%3A%2F%2Flocalhost%3A44316%2F&scope=openid&response_type=id_token&prompt=login

但是,这是我的应用奇怪地重定向到的网址:# login.microsoftonline.com/XXX.onmicrosoft.com/oauth2/v2.0/authorize?p=b2c_1_signin?client_id=XXXXX&redirect_uri=https%3a%2f%2flocalhost%3a44316%2f&response_mode=form_post&response_type=id_token&范围=的OpenID&安培;状态= OpenIdConnect.AuthenticationProperties%3d1dRzpEoUYWC8q6vPoGU3VtcY7wXXmMDVlkWqr8aQLvWqv64IWeGE0jUnQ6chCZBWEo55uYHsSD27R6EjKIlEaEQWdH6dgIrNDj_n234nLkHb7bKsToir8Yr8j7gbXPb7dBG00wlOufyOfXRT29owsOzjJ8WWwguWDWlo2MN3McsuIWflDKup5qCtQTUS71RBGAEbcQJ_1BqFxIUZsbTglEg4KGm-mroT0tz7PGDcRQU&安培;随机数= 636311347285953639.YzQyOWNmYjQtNzAxOS00MTBmLTlkYzQtZGM4MjNlNjdjYThlM2ZlMWMxZGEtYWE0MS00YzY3LWFiM2MtZDgyZWNiNGUxOWQ0

However this is the url that my app strangely redirects to: # login.microsoftonline.com/XXX.onmicrosoft.com/oauth2/v2.0/authorize?p=b2c_1_signin?client_id=XXXXX&redirect_uri=https%3a%2f%2flocalhost%3a44316%2f&response_mode=form_post&response_type=id_token&scope=openid&state=OpenIdConnect.AuthenticationProperties%3d1dRzpEoUYWC8q6vPoGU3VtcY7wXXmMDVlkWqr8aQLvWqv64IWeGE0jUnQ6chCZBWEo55uYHsSD27R6EjKIlEaEQWdH6dgIrNDj_n234nLkHb7bKsToir8Yr8j7gbXPb7dBG00wlOufyOfXRT29owsOzjJ8WWwguWDWlo2MN3McsuIWflDKup5qCtQTUS71RBGAEbcQJ_1BqFxIUZsbTglEg4KGm-mroT0tz7PGDcRQU&nonce=636311347285953639.YzQyOWNmYjQtNzAxOS00MTBmLTlkYzQtZGM4MjNlNjdjYThlM2ZlMWMxZGEtYWE0MS00YzY3LWFiM2MtZDgyZWNiNGUxOWQ0

我完全从工作示例中复制了代码,但没有成功.我什至从头开始创建了一个全新的mvc项目,并从示例项目中复制了代码,但该代码仍然无法正常工作.当它重定向到该URL时,它显示404-找不到文件或目录. 您正在寻找的资源可能已被删除,名称已更改或暂时不可用.

I copied the code exactly from the working sample and it didn't work. I even created a whole new mvc project from scratch and I copied the code from the sample project and it still didn't work. When it redirects to that url it shows 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.

我很确定答案是显而易见的,我看起来会很傻,但是我在这里拉头发,任何输入都非常感谢.

I am pretty sure the answer is quite obvious and I will look very silly but I'm pulling my hair here and any input is really appreciated.

推荐答案

没关系,通过将Microsoft.IdentityModel.Protocol.Extensions更新到1.0.4.4或更高版本,解决了该问题.

Nevermind guys the problem was resolved by updating Microsoft.IdentityModel.Protocol.Extensions to version 1.0.4.4 or later.

希望这对仍在为此奋斗的人有所帮助.

Hope this helps anyone who is still struggling with this.

这篇关于Azure B2C GetOwinContext().Authentication.Challenge使用问号而不是And符号创建错误的url的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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