Session per Request in ASP.NET Core

78 views
Skip to first unread message

Felipe Oriani

unread,
Nov 14, 2019, 12:04:59 PM11/14/19
to nhu...@googlegroups.com
Hi everyone.

I have been working with NHibernate since the 2.x.x and I always use the ORM with the a Session/Transaction per Request with Asp.Net on .Net Framework. It always worked very well on production with a lot of users.

Now, I am starting a new project with ASP.NET Core and I do not have a lot of experience with this new platform. I have been searching on web about how to implement session per request on ASP.NET Core. Could someone share any material or some guids how to implement it?

Do I need to use a middleware? Is there any way to configure the session context and define it on IoC container to inject the ISessionFactory?

Thank you.

--
______________________________________
Felipe B Oriani

Carlos Alberto Costa Beppler

unread,
Nov 18, 2019, 9:43:15 AM11/18/19
to nhusers
An simple form is register ISessionFactory on DI using singlteton scope and register ISession on DI using request scope (resolving it using the ISessionFactory registered as singleton).

Then make your controllers dependent on ISession.
Reply all
Reply to author
Forward
0 new messages