dotnet/systemweb-adapters

Ask About HttpContext.SetSessionStateBehavior

Clounea opened this issue · 3 comments

Summary

Our repo uses HttpContext.SetSessionStateBehavior which are not supported by ASP.NetCore and this adapters.
I want to ask if there is equivalent and if there is plan to add them to adapter.

Motivation and goals

We need migrate code (an API in Sharepoint) to ASP.NetCore and we find that the APIs are not supported by ASP.NetCore.

In scope

  • HttpContext.SetSessionStateBehavior
  • HttpContext.SessionStateBehavior

From src code, It seems that the property is used to decide whether to acquire session state. But in the adapter, the session state is gotten from the feature.
I wonder if SetSessionStateBehavior is still needed.

Examples

Here is an example of HttpContext.SetSessionStateBehavior

if (IsDataAPI(context))
{
    context.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Disabled);
}

What's the context this is used in? We currently decide if session is enabled by the SessionAttribute as metadata on the endpoint. In order to enable this, we'll need a per-request flag that could be set and checked in the SessionMiddleware.

@twsouthwick The context is that, for specific url pattern, We don't want to use session state.

The thing which makes it complex is that, we don't use the ASP.NetCore endpoint, we use Microsoft.Owin to process the endpoints and wrap them in ASP.NetCore.

Do you have suggestions?

@Clounea What I would recommend is to add a new feature:

internal interface ISessionStateFeature
{
  SessionStateBehavior State { get; set; }
}

behavior should probably be:

  1. If the state is set here, have it be surfaced
  2. If no state is set via the feature, default to the existing endpoint metadata if it is available

The Sessionmiddleware will need to be updated to handle this change (i.e. use this feature rather than metadata)