Asp.net mvc 4 未从OWIN调用Azure B2C登录策略自定义页面URI

Asp.net mvc 4 未从OWIN调用Azure B2C登录策略自定义页面URI,asp.net-mvc-4,owin,azure-ad-b2c,Asp.net Mvc 4,Owin,Azure Ad B2c,我在blob存储中设置了登录策略自定义页面URI,但它总是转到Microsoft登录页面。我使用的owin和代码如下: public void ConfigureAuth(IAppBuilder app) { app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType); app.UseCookieAuthentication(new Co

我在blob存储中设置了登录策略自定义页面URI,但它总是转到Microsoft登录页面。我使用的owin和代码如下:

 public void ConfigureAuth(IAppBuilder app)
 {                 app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

 app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = authority,
                PostLogoutRedirectUri = postLogoutRedirectUri,
                RedirectUri = postLogoutRedirectUri,
                Notifications = new OpenIdConnectAuthenticationNotifications
                {
                    AuthenticationFailed = context =>
                    {
                        context.HandleResponse();
                        context.Response.Redirect("/Error?message=" + context.Exception.Message);
                        return Task.FromResult(0);
                    }
                }
            });
    }
页面已配置且正在运行

下面是我正在使用的URL

 <add key="ida:AADInstance" value="https://login.microsoftonline.com/te/{0}/{1}/v2.0/.well-known/openid-configuration" />
以下是Microsoft默认登录屏幕:

如果您仍在获得404错误,您可以考虑检查以下内容:

检查B2C策略的元数据端点,并基于该端点创建AADInstance url。例如,在我的政策中,我有以下几点: 所以我会有一个AADInstance url={0}/v2.0/.well-known/openid配置?p={1}

在OpenIdConnectAuthenticationOptions中,使用Metadata属性而不是Authority,并从元数据端点使用上述AADInstance

新的OpenIdConnectAuthenticationOptions { ClientId=ClientId,
MetadataAddress=String.Format,目前,只能使用公司品牌功能自定义本地帐户登录页、其附带的密码重置页和验证电子邮件。

别介意,问题已通过将Microsoft.IdentityModel.Protocol.Extensions更新到1.0.4.4或更高版本得到解决


希望这能帮助那些仍在挣扎的人。

你能添加你所指的Microsoft登录页面的屏幕截图吗?@Saca:我已经用Microsoft登录页面更新了问题。什么时候你会收到404错误?如果页面看起来很成功,但没有你的自定义,我将面临与之前相同的问题在下面的例子中,我看到了从owin生成的不同URL,在本例中,我得到了404错误:您看到的不同URL是什么?您是否根据StackOverflow帖子更新了与身份相关的nugget包?
 Response status code does not indicate success: 404 (Not Found). 

 Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

 Exception Details: System.Net.Http.HttpRequestException: Response status code does not indicate success: 404 (Not Found).