Skip to content
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

How to share "System.Web.HttpContext.Current.Session" between ASP.NET and .NET CORE application #570

Closed
marjanz-lsoft opened this issue Dec 19, 2024 · 2 comments
Labels
Needs: Author Feedback Issues and PRs that are waiting on the author's response Status: No Recent Activity Issues and PRs that have not been updated in a while.

Comments

@marjanz-lsoft
Copy link

marjanz-lsoft commented Dec 19, 2024

Dear All,

I would like to share session values between ASP.NET and ASP.NET CORE application. It is working fine only when the session value is set inside "Session_Start() method in Global.asax.cs. When I try to set session value in an other action in an other controller of the ASP.NET application, the session value is NULL in the .NET CORE application.

What am I doing wrong?

program.cs:

// Creating listener:
(...)
_.AddSystemWebAdapters()
.AddJsonSessionSerializer(options =>
{
    options.RegisterKey<string>("testvalueString");
})
.AddSessionSerializer(options =>
{
   options.ThrowOnUnknownSessionKey = true;
})
.AddRemoteAppClient(options =>
{ 
    options.RemoteAppUrl = new Uri("http://localhost:65020/teszt/ind/");//http://localhost:65020/teszt/ind/
    options.ApiKey = "4ffb49b3-2aa3-40b3-96ca-1b5331aab2dc";
})
.AddSessionClient();_

// Creating server, (Global.asax.cs, Application_Start() action)

(...)
_.AddSystemWebAdapters(this)
.AddJsonSessionSerializer(options =>
{
    options.RegisterKey<string>("testvalueString");
    options.RegisterKey<DateTime>("tesvalueDateTime");
})
.AddSessionSerializer(options =>
{
    options.ThrowOnUnknownSessionKey = true;
})
.AddRemoteAppServer(options =>
{       options.ApiKey = "4ffb49b3-2aa3-40b3-96ca-1b5331aab2dc";// "<A strong, unique key>";
})
.AddSessionServer();_

Settins session value:

_System.Web.HttpContext.Current.Session["testvalueString"] = "Test value";_

Versions: I am using SystemWebAdapters 1.4.0 and .Net 8.

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

Can you provide a bit more detail as to how you're accessing the session values? A minimal repro maybe?

If it helps, have you tried out the "RemoteSession" sample in this repo?

@twsouthwick twsouthwick added Needs: Author Feedback Issues and PRs that are waiting on the author's response and removed Needs: Triage 🔍 Label added to new issues which need Triage labels Jan 6, 2025
@dotnet-policy-service dotnet-policy-service bot added the Status: No Recent Activity Issues and PRs that have not been updated in a while. label Jan 23, 2025
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 15 days. It will be closed if no further activity occurs within 15 days of this comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs: Author Feedback Issues and PRs that are waiting on the author's response Status: No Recent Activity Issues and PRs that have not been updated in a while.
Projects
None yet
Development

No branches or pull requests

2 participants