未在本地 IIS 中调用 ADFS OWIN 身份验证

ADFS OWIN authentication not invoked in local IIS

我正在尝试确定如何设置 MVC 应用程序以针对本地 ADFS 服务器进行身份验证。我正在使用 the Github Azure Samples and altered it as described in Vittorio Bertocci's blog 中的 Azure AD 示例来使用我的应用程序的 RealmId 和我的组织的 ADFS 元数据端点。当我 运行 使用 IIS Express 的示例时,OWIN 中间件被调用,我得到重定向到 ADFS 登录屏幕。

但是,我正在开发的应用程序需要在 IIS 中 运行,因此我尝试在本地 IIS 中配置我的示例应用程序。当我 运行 本地 IIS 中的样本时,没有重定向到 ADFS,而是返回 windows (Kerberos) 身份。如何确保 IIS 调用 OWIN 中间件?应用程序池在集成 v4.0 模式下 运行ning。

这是我的代码 Startup.Auth.cs:

private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
    private static string metadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];

    public void ConfigureAuth(IAppBuilder app)
    {

        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

        app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseWsFederationAuthentication(
            new WsFederationAuthenticationOptions
            {
                Wtrealm = realm,
                MetadataAddress = metadata,
                Notifications = new WsFederationAuthenticationNotifications
                {
                    AuthenticationFailed = context =>
                    {
                        context.HandleResponse();
                        context.Response.Redirect("Home/Error?message=" + context.Exception.Message);
                        return Task.FromResult(0);
                    }
                }
            });
    }

IIS 中为您的应用程序设置的“身份验证”选项卡是什么?

您是否启用了表单或Windows身份验证?

如果启用的唯一项目是匿名会怎样?