aspnet / AspNetKatana

Microsoft's OWIN implementation, the Katana project
Apache License 2.0
967 stars 334 forks source link

SystemWebChunkingCookieManager not working #355

Closed mrcferri closed 4 years ago

mrcferri commented 4 years ago

Using the default ChunkingCookieManager everything worked fine, except occasional redirect loops, as widely known with ASP.NET (#197). To avoid bad surprises, before going in production I switched to SystemWebChunkingCookieManager as suggested. However, for some reason the authentication cookie is not sent. Any hints to solve this problem?

Tratcher commented 4 years ago
mrcferri commented 4 years ago

The Startup code is quite simple

        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies",
                CookieManager = new Microsoft.Owin.Host.SystemWeb.SystemWebChunkingCookieManager(),
                LoginPath = new PathString("/login")
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
    //  Google, Twitter & Facebook handlers follow...
    }

Package version: 4.1 IIS: 8.5 MVC: 5.2

I follow your instructions to output tracing to a file, but I didn't get any output and nothing I saw in VS console related to Microsoft.Owin.

Currently, I'm testing locally.

Tratcher commented 4 years ago

Looks ok. Can you share a Fiddler trace file?

mrcferri commented 4 years ago

Actually, my code wasn't right. I just copied an example using SystemWebChunkingCookieManager, where ApplicationType was set to "Cookies", directly as a string. Reverting to my original code

AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie;

everything works fine. In fact, the correct value to assign is "ApplicationCookie" not "Cookies".

By the way, does SystemWebChunkingCookieManager get rid of the redirect loop once for all? And maybe even of the occasional "Server cannot append header after HTTP headers have been sent" error?

Thanks a lot.

Tratcher commented 4 years ago

There are several kinds of redirect loops, but it does address the missing auth cookie one.

"Server cannot append header" is a different issue related to child requests. https://github.com/aspnet/AspNetKatana/issues/74