admin管理员组

文章数量:1128974

I have an ASP.NET webforms and a Web API that locally in IIS Express, automatically calls my custom identity server when user navigates to a specific web page, firing the OnRedirectToIdentityProvider event.

If I publish this application to IIS, nothing happens (when users click on login link page, the code returns http 200 instead of triggering above mentioned event).

This is my code:

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    AuthenticationMode =  Microsoft.Owin.Security.AuthenticationMode.Passive
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
    AuthenticationType = OpenIdConnectAuthenticationDefaults.AuthenticationType, //"oidc";
    ClientId = WebConfigurationManager.AppSettings["ClientId"],
    BackchannelTimeout = System.TimeSpan.FromMinutes(30),
    CallbackPath = new PathString("/Account/Login"),        
    Authority = WebConfigurationManager.AppSettings["Authority"],
    PostLogoutRedirectUri = WebConfigurationManager.AppSettings["PostLogoutRedirectUri"],
    RedirectUri = WebConfigurationManager.AppSettings["RedirectUri"],
    Scope = "openid profile",
    ResponseType = "id_token",
    SaveTokens = true,
    Notifications = new OpenIdConnectAuthenticationNotifications
    {
        AuthenticationFailed = OnAuthenticationFailed,
        SecurityTokenValidated = OnSecurityTokenValidated,
        RedirectToIdentityProvider = OnRedirectToIdentityProvider,
        MessageReceived = OnMessageReceived,
        AuthorizationCodeReceived = OnAuthorizationCodeReceived,
        TokenResponseReceived = OnTokenResponseReceived,
        SecurityTokenReceived = OnSecurityTokenReceived,
    }
});

app.UseStageMarker(PipelineStage.Authenticate);

I have an ASP.NET webforms and a Web API that locally in IIS Express, automatically calls my custom identity server when user navigates to a specific web page, firing the OnRedirectToIdentityProvider event.

If I publish this application to IIS, nothing happens (when users click on login link page, the code returns http 200 instead of triggering above mentioned event).

This is my code:

app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    AuthenticationMode =  Microsoft.Owin.Security.AuthenticationMode.Passive
});

app.UseOpenIdConnectAuthentication(new OpenIdConnectAuthenticationOptions
{
    AuthenticationType = OpenIdConnectAuthenticationDefaults.AuthenticationType, //"oidc";
    ClientId = WebConfigurationManager.AppSettings["ClientId"],
    BackchannelTimeout = System.TimeSpan.FromMinutes(30),
    CallbackPath = new PathString("/Account/Login"),        
    Authority = WebConfigurationManager.AppSettings["Authority"],
    PostLogoutRedirectUri = WebConfigurationManager.AppSettings["PostLogoutRedirectUri"],
    RedirectUri = WebConfigurationManager.AppSettings["RedirectUri"],
    Scope = "openid profile",
    ResponseType = "id_token",
    SaveTokens = true,
    Notifications = new OpenIdConnectAuthenticationNotifications
    {
        AuthenticationFailed = OnAuthenticationFailed,
        SecurityTokenValidated = OnSecurityTokenValidated,
        RedirectToIdentityProvider = OnRedirectToIdentityProvider,
        MessageReceived = OnMessageReceived,
        AuthorizationCodeReceived = OnAuthorizationCodeReceived,
        TokenResponseReceived = OnTokenResponseReceived,
        SecurityTokenReceived = OnSecurityTokenReceived,
    }
});

app.UseStageMarker(PipelineStage.Authenticate);
Share Improve this question edited Jan 8 at 21:04 marc_s 754k183 gold badges1.4k silver badges1.5k bronze badges asked Jan 8 at 11:53 Daniele FrisennaDaniele Frisenna 195 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

I found a solution by myself. All my code and related libraries wasn't have any problems. The working solution was to delete bad nested web config files located in the same directory where are present the destination link aspx file, that disable middleware redirect.

本文标签: netOnRedirectToIdentityProvider does not fire when publish my ASPNET webforms app on IISStack Overflow