How to initialize OWIN from Session_Start (Global.asax.cs) and not from Startup.cs?

Mar 15, 2015 at 6:50 PM
I would like to initialize OWIN (Function: ConfigureAuth(IAppBuilder app) from Session_Start in Global.asax.cs and not from Startup.cs. (My app uses MVC 5 / identity 2.2).

This is so I can set the connectionString for ApplicationDbContext() in Session_Start.

My app is for different regions and each region has its own set of users and data that are independent of all the other regions. Therefore, I want to have separate user databases (for ApplicationDbContext). I have the info I need to set the connection string in Session_Start, but not in Startup.cs.

To achieve this goal, I was thinking the easiest would be call ConfigureAuth() from Session_Start, but I don’t know how to do that. Thanks in advance for assistance.