Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sgarnovsky opened this issue Dec 5, 2023 · 5 comments · Fixed by #463
Labels
In-PR Issues that have a PR open for them. Needs: Triage 🔍 Label added to new issues which need Triage

Comments

@sgarnovsky
Copy link

sgarnovsky commented Dec 5, 2023

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.

@dotnet-policy-service dotnet-policy-service bot added the Needs: Triage 🔍 Label added to new issues which need Triage label Dec 5, 2023
@joperezr
Copy link
Member

joperezr commented Dec 6, 2023

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

@sgarnovsky
Copy link
Author

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
Copy link

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
Copy link

@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

@dotnet-policy-service dotnet-policy-service bot added the In-PR Issues that have a PR open for them. label Jan 9, 2024
twsouthwick added a commit that referenced this issue Jan 9, 2024
As part of expanding the session support to enable per request changing the session behavior in #399, it appears that the default `SessionAttribute` was changed to have a different default value.

Fixes #455
@sgarnovsky
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
In-PR Issues that have a PR open for them. Needs: Triage 🔍 Label added to new issues which need Triage
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants