Description
I am trying to Set Session variable in .NET framework application and access it in .NET 7 application using link https://learn.microsoft.com/en-us/aspnet/core/migration/inc/remote-session?view=aspnetcore-7.0 however I am unable to get value of session variable in .NET Core.
I did following changes
.NET Framework -
Added Nuget package Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices
Added below code in global.asax.cs -Application_Start function
SystemWebAdapterConfiguration.AddSystemWebAdapters(this)
.AddJsonSessionSerializer(options =>
{
// Serialization/deserialization requires each session key to be registered to a type
options.RegisterKey("test");
})
// Provide a strong API key that will be used to authenticate the request on the remote app for querying the session
// ApiKey is a string representing a GUID
.AddRemoteAppServer(options => options.ApiKey = "03f74e3e-d690-4806-b0a7-e66f89215bb3")
.AddSessionServer();
.NET 7 Changes
builder.Services.AddSystemWebAdapters()
.AddJsonSessionSerializer(options =>
{
// Serialization/deserialization requires each session key to be registered to a type
options.RegisterKey("test");
}) .AddRemoteAppClient(options =>
{
// Provide the URL for the remote app that has enabled session querying
options.RemoteAppUrl = new(builder.Configuration["ReverseProxy:Clusters:fallbackCluster:Destinations:fallbackApp:Address"]);
// Provide a strong API key that will be used to authenticate the request on the remote app for querying the session
options.ApiKey = "03f74e3e-d690-4806-b0a7-e66f89215bb3";
})
.AddSessionClient();
Added app.MapDefaultControllerRoute().RequireSystemWebAdapterSession(); ;