genialguy
genialguy

Reputation: 11

sharing session between owin web form and regular web form

I'm new to owin, OAuth, OpenID connect terminology. I'm trying learn as much as possible. I work with legacy .net web forms application. I have 2 webforms app. App_1 is more like a dashboard/landing page application. App_2 is the main application that has all the functionalities. I use Identity server 4 for authentication only(don't ask me why). this is the flow: 1) user logs in using IS4 and lands in App_1. 2) all the metadata required for the authorization and business logic is stored in the session object in app_1 page load 3) the user then goes to app_2. it retrieves required data from the session object

previously there was no IS4 authentication. it was using forms authentication and the session concept was working fine. I just changed authentication to IS4 then the session object became null.

I tried various solutions suggested on the internet. It didn't work. I added this in app_1 startup.cs, but still it failed.

        app.Use((context, next) =>
        {
            var httpContext = context.Get<HttpContextBase>(typeof(HttpContextBase).FullName);
            httpContext.SetSessionStateBehavior(SessionStateBehavior.Required);
            return next();
        });

        app.UseCookieAuthentication(new CookieAuthenticationOptions()
        {
            AuthenticationType = "Cookies",
            ExpireTimeSpan = TimeSpan.FromMinutes(10),
            CookieName="MyWebApp",
            SlidingExpiration = true
        });

Note: im also having the same machine key to in web.config of both the web apps.

Can anyone please tell me how to carry the session object between these 2 web apps?

Upvotes: 1

Views: 48

Answers (0)

Related Questions