简体   繁体   中英

How to share sessions between ASP.NET Web Apps in same machine and same application pool?

I have two ASP.NET Web apps in same machine;

1) ASP.NET WebForm web app - wwwroot/publicsite
2) ASP.NET MVC web app – wwwroot/test/mysite

I can create an application pool and set it to both web app.

Is there any simple way to share session between two web apps without using custom session provider through DB?
(like modifying web.config and so)

Best regards.

So, i don't have this developed yet, so i'll describe the scenario and when i have it coded i can edit this answer, but short term here it is:

You can edit your page class (and use that custom page class or HttpApplication class) to "save" the session objects using serialization into a cookie, and get that cookie on load (or begin request if set on the httpapplication) of a page. So any site would query the same cookies for session objects (since the SessionState class is basically a collection of objects - see MSDN Code Page for SessionState ). All you need if for both applications to use the same base class with the custom Page (or HttpApplication) class that serializes and deserialize the session objects on Begin Request and Write Response times.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM