dotnet / systemweb-adapters

MIT License
337 stars 59 forks source link

System.Web.HttpContext.Session is null with SystemWebAdapters v1.3.0 on .Net 8 after upgrading the 1.20 version on .Net 6. #455

Closed sgarnovsky closed 9 months ago

sgarnovsky commented 10 months ago

Originally I'd already created a project using .Net 6 and SystemWebAdapters using version 1.2.0 and it worked fine.

After migrating to the .Net 8 and SystemWebAdapters 1.3.0 (nuget package) Session from the System.Web.HttpContext is returned as a null reference.

Initialization code is:

services.AddSystemWebAdapters() .AddSessionSerializer() .AddMssAdminSessionSerializer() .AddRemoteAppClient(options => { options.RemoteAppUrl = new(Configuration.GetMigrationLegacyAppAddress()); options.ApiKey = Configuration.GetMigrationRemoteAPIKey(); }) .AddSessionClient();

app.MapRazorPages() .RequireSystemWebAdapterSession();

One thing I see that this github project refers 1.2.0 version only. It is possible the 1.3.0 has changed initialization steps or maybe just moved the source to another place?

So for now, I just downgraded the SystemWebAdapters packages back to 1.2.0 version. Confirmed the Session sharing works fine under .Net 8 in this case.

joperezr commented 10 months ago

Thanks for logging this @sgarnovsky, it looks like this is a dupe of #453 ?

sgarnovsky commented 10 months ago

Yes, originally I thought it was the same, but now I'm not sure. Please let me know if you know any additional set up is required while switching from 1.2 to 1.3 version of the package to make the session sharing work.

erpardeepkaushik commented 9 months ago

Hello, i tried an example but seems .net8 and yarp 1.3 is not working together or there is a bug in VS2022. i always get the session values null in asp.net core app. but downgrading to all packages of system web adaptors to 1.2 works seamlessly. please advise what could be the issue. please find the repos links with ver 1.3

https://github.com/erpardeepkaushik/TestWebCore https://github.com/erpardeepkaushik/TestWeb

asajjad308 commented 9 months ago

@erpardeepkaushik in my case if i use protected void Session_Start(Object sender, EventArgs e) { HttpContext.Current.Session["sk"] =30;

    } i get value in core app but not getting value if i initialize session from controller
sgarnovsky commented 2 weeks ago

Upgrading from the 1.2.0 to 1.4.0 doesn't show this issue anymore. I guess it was fixed with 1.3.1 version.