ASP.NET Web表单网站-使用OWIN KATANA与多个ADF集成

ASP.NET Web表单网站-使用OWIN KATANA与多个ADF集成,asp.net,webforms,owin,ws-federation,adfs3.0,Asp.net,Webforms,Owin,Ws Federation,Adfs3.0,我正在将旧的现有web窗体网站配置为多租户环境。一个要求是能够与多个客户端ADF集成。 我遵循并成功实现了一个支持多个ADF的MVC应用程序。但是我仍然面临一个问题,, 这在MVC应用程序中是不可复制的。在我的web表单站点中,只有第一个ADFS提供程序注册成功。第二个总是 在验证并返回到我的站点后抛出SignatureRefercationFailedException(异常发生在我这边)。 这与我在OWIN启动配置中使用app.Map(…)还是app.use(…)无关。 我尝试将我的网站转换

我正在将旧的现有web窗体网站配置为多租户环境。一个要求是能够与多个客户端ADF集成。 我遵循并成功实现了一个支持多个ADF的MVC应用程序。但是我仍然面临一个问题,, 这在MVC应用程序中是不可复制的。在我的web表单站点中,只有第一个ADFS提供程序注册成功。第二个总是 在验证并返回到我的站点后抛出SignatureRefercationFailedException(异常发生在我这边)。 这与我在OWIN启动配置中使用app.Map(…)还是app.use(…)无关。
我尝试将我的网站转换为web应用程序,但结果相同。我想这与WEB表单中处理请求的方式有关,这与MVC不同

我应该以不同的方式处理中间件映射吗?
我错过了什么<或者这根本不可能

以下是我的OWIN启动配置:

app.Properties["Microsoft.Owin.Security.Constants.DefaultSignInAsAuthenticationType"] = Config.ExternalAuthentication.Cookie;
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = Config.ExternalAuthentication.Cookie,
    AuthenticationMode = Microsoft.Owin.Security.AuthenticationMode.Passive
});

string wreply = Config.ExternalAuthentication.Wreply;
string wtrealm = Config.ExternalAuthentication.Wtrealm;

List<Company> adfsCompanies = BL.GetCompaniesWithADFS();
app.Map("/Public/Login.aspx", configuration =>
{
    foreach (Company company in adfsCompanies)
    {
        //configure middleware
        var middleware = new WsFederationAuthenticationOptions()
        {
            MetadataAddress = company.ADFSMetadataUrl,
            AuthenticationType = company.TenantName,
            Caption = company.Name,
            Wreply = wreply,
            Wtrealm = wtrealm,
            BackchannelCertificateValidator = null
        };      

        //add to pipeline
        configuration.UseWsFederationAuthentication(middleware);
    }
});
无论我做什么,只有第一个注册的ADFS中间件成功,不管是哪一个。我还尝试将中间件连接到不同的管道阶段,但没有成功


提前感谢您的帮助

对于多个wsfed中间件,每个都应设置唯一的WsFederationAuthenticationOptions.CallbackPath,例如“/ws1”。您还需要将此值包含在wreply中。

我只是对@Tratcher建议的解决方案提供了更多细节,以保持问题的简洁明了:

1) ,
CallbackPath
如果未设置,则根据
Wreply
计算

2) 在区分每个提供者的
Wreply
之后,结果证明这是不够的,因为还出现了其他问题。然后我发现(使用我的MVC工作示例),而且
Wtrealm
Wreply
应该具有相同的值

3) 在ASP.NET Web表单中为不同的提供者设置不同的URL并不是那么容易。假URL不起作用。使用URL重写-也可以
最简单的解决方案是为每个提供程序使用不同的回调页面(例如ExternalLoginFirstADFS.aspx、ExternalLoginSecondADFS.aspx等)。这虽然工作正常,但不是最好的,因此我决定在Global.asax中的
Application\u Start
事件中为每个提供者配置一个路由,如下所示:

void Application_Start(object sender, EventArgs e)
{
    ...
    RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}

public static void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
    List<Organization> adfsCompanies = OrgElementEntity.GetCompaniesWithADFS();
    foreach(Organization company in adfsCompanies)
    {
        routes.MapPageRoute("",
            String.Format("Public/ExternalLogin{0}.aspx", company.TenantName),
            "~/Public/ExternalLogin.aspx");
    }
}
void应用程序\u启动(对象发送方,事件参数e)
{
...
RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}
公共静态无效注册表项(System.Web.Routing.RouteCollection routes)
{
列出ADFScompanys=OrgElementEntity.GetCompanyWithADFS();
foreach(ADFSCompanys中的组织公司)
{
routes.MapPageRoute(“”,
格式(“Public/ExternalLogin{0}.aspx”,company.TenantName),
“~/Public/ExternalLogin.aspx”);
}
}

此外,事实证明,在
OwinStartup
上使用
app.Map(…)
。只需通过app.usewsferationauthentication(…)添加每个中间件就可以了

非常感谢,@Tratcher。你的回答并没有给出完整的解决方案,但它却把我引向了正确的方向。为了保持问题的简洁明了,我将给出更多的细节和一个答案
void Application_Start(object sender, EventArgs e)
{
    ...
    RegisterRoutes(System.Web.Routing.RouteTable.Routes);
}

public static void RegisterRoutes(System.Web.Routing.RouteCollection routes)
{
    List<Organization> adfsCompanies = OrgElementEntity.GetCompaniesWithADFS();
    foreach(Organization company in adfsCompanies)
    {
        routes.MapPageRoute("",
            String.Format("Public/ExternalLogin{0}.aspx", company.TenantName),
            "~/Public/ExternalLogin.aspx");
    }
}