Skip to content

How do I dynamically register a session key? #311

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
aetos382 opened this issue Mar 22, 2023 · 3 comments
Closed

How do I dynamically register a session key? #311

aetos382 opened this issue Mar 22, 2023 · 3 comments
Labels
question Further information is requested up for grabs We'd accept a contribution for this
Milestone

Comments

@aetos382
Copy link

aetos382 commented Mar 22, 2023

In my legacy application, I have session items that are dynamically named at runtime based on request parameters.
How do I register such keys with JsonSessionSerializerOptions?

For example, could you consider supporting the following functionality?

class JsonSessionSerializerOptions
{
    public void RegisterKey<T>(
        Func<HttpContext, string> sessionNameFactory);
}
@twsouthwick
Copy link
Member

The json serialization out of the box is intended for known keys. If you want to register dynamic keys, you'll need to register your own ISessionKeySerializer.

If you want to be able to use dynamic keys with the json session serialization, we'd need a way to plumb that through. Feel free to explore a POC there if you want.

@joperezr joperezr added the question Further information is requested label Mar 29, 2023
@joperezr
Copy link
Member

joperezr commented Mar 29, 2023

Discussed this during triage. Might be interesting to add a sample that shows how you can register your own ISessionKeySerializer. If anyone is interested in adding a sample before we get to this, let us know 😄

@joperezr joperezr added the up for grabs We'd accept a contribution for this label Mar 29, 2023
@joperezr joperezr added this to the Backlog milestone Mar 29, 2023
@twsouthwick
Copy link
Member

I've added a sample and updated things so that you can register multiple ISessionKeySerializer instances and a composite of all of them will be used to serialize/deserialize session state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested up for grabs We'd accept a contribution for this
Projects
None yet
Development

No branches or pull requests

3 participants