Finbuckle / Finbuckle.MultiTenant

Finbuckle.MultiTenant is an open-source multitenancy middleware library for .NET. It enables tenant resolution, per-tenant app behavior, and per-tenant data isolation.
https://www.finbuckle.com/multitenant
Apache License 2.0
1.3k stars 265 forks source link

Question: Is it possible to get MultiTenantContext (using extension method) while making Ajax calls? #127

Closed pjtalkstech closed 5 years ago

pjtalkstech commented 5 years ago

I see the source code GetMultiTenantContext extension method relies on HttpContext's Items dictionary property. If it is full page post back Items property has tenant information. If it is Ajax call Items property is empty. Is there way to make it work for Ajax calls.

Sorry if this previously answered.

AndrewTriesToCode commented 5 years ago

Hi @chintupawan

This is a great question. I don't do much front-end stuff so I hope I can help. Are you using CORS? Does an Ajax call route into the correct controller/action?

Can you post the Ajax code you are using? Can you also post your ConfigureServices and Configure methods in the ASP.NET Core startup?

In theory an Ajax call should work just like a regular call from ASP.NET Core's perspective.

I am traveling this week, but I can take a closer look this weekend.

pjtalkstech commented 5 years ago

@achandlerwhite thanks for your quick response. I was using Finbuckle Multitent Middleware inside another Middleware. My order of registration of these Middlewares are wrong. Multitenant Middleware should go first. Once I do this I see Items property is filled with MultiTenantContext.

Thanks

AndrewTriesToCode commented 5 years ago

I’m glad you figured it out. Let me know if you run into any more problems.