Base solution for your next web application
Open Closed

Can I set the tenant and persist to session without login? #2219


User avatar
0
danhirsch created

I added a domain name to the tenant object - and I know how to get to that in the startup... but before I write all the structure to persist the tenant (without logging in) to the session myself...wondering if there is a good way to get to persist that tenant object (serialized json of course) into the session using the constructs that are already in asp.net boilerplate?

Basically - I want to allow for some customizable/individualized content by tenant without an authenticated user and for the user to not have to enter the tenant when logging in or registering.

I also don't want to just set the tenant ID and have to get the tenant object from the db every time I want access to the object.

This isn't really hard to do normally - but wanted to use the existing structure if possible...

I don't see any way to extend the AbpSession/IAbpSession object/interface without getting the source, adding, and recompiling either...


4 Answer(s)
  • User Avatar
    0
    danhirsch created

    In response - the way I will facilitate it is to look up the tenant by a domainurl added to the tenant object....

  • User Avatar
    0
    hikalkan created
    Support Team

    Hi,

    You can not add properties to IAbpSession, but you can easily define IYourSession interface which may extend IAbpSession.

    Anyway, you have a few options.

    I would create a serializable TenantInfo object and add it to the Cookie. Then, in every request you can deserialize it and read values. If you need, you can encrypt it. Thus, you can create a stateless solution.

    Another option would be using a server side cache (<a class="postlink" href="http://www.aspnetboilerplate.com/Pages/Documents/Caching">http://www.aspnetboilerplate.com/Pages/ ... ts/Caching</a>)

    Have a nice day.

  • User Avatar
    0
    danhirsch created

    Thanks for the reply - is the cache session specific?

    Thanks again!

  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    No cache is not related to sesssion, it is not session specific.