Our framework webform projects has many session variables.
Per SystemWebAdapter, I need to list of them by AddJsonSessionSerializer in Application_Start
Is it possible that I can limit them to that used in .Net Core project only?
I have tried not listing them all and got this error: “Unknown session keys
Here is the Framework code snap with two session variables: Company and Employee. But only Employee is set to share
protected void Application_Start(object sender, EventArgs e)
{
SystemWebAdapterConfiguration.AddSystemWebAdapters(this)
.AddJsonSessionSerializer(options => {
options.RegisterKey<ArrayList>("Employee");
})
.AddRemoteAppServer(
options => {
options.ApiKey = "4ffb49b3-2aa3-40b3-96ca-1b5331aab2dc";
}
).AddSessionServer();
}
protected void Session_Start(object sender, EventArgs e)
{
System.Web.HttpContext.Current.Session["Company"] = "ABC";
System.Web.HttpContext.Current.Session["Employee"] = "John";
}
Here is program.cs
using Core;
using System.Collections;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddTransient<GlobalExceptionHandlerMiddleware>();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSystemWebAdapters()
.AddJsonSessionSerializer(options => {
options.RegisterKey<ArrayList>("Employee");
})
.AddRemoteAppClient(options => {
options.RemoteAppUrl = new Uri("http://192.168.56.1");
options.ApiKey = "4ffb49b3-2aa3-40b3-96ca-1b5331aab2dc";
}).AddSessionClient();
var app = builder.Build();
app.UseSwagger();
app.UseSwaggerUI();
app.UseMiddleware<GlobalExceptionHandlerMiddleware>();
app.UseAuthorization();
app.UseSystemWebAdapters();
app.MapControllers();
app.Run();
Thanks
user25654022 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.