# Properly Setting up .Net WebApi using Owin for Multi Tenants

**URL:** <https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223>\
**Category:** Get Help\
**Tags:** webapi, .net, owin\
**Created:** [September 17, 2017, 11:59pm UTC](https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223 "2017-09-17T23:59:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremy11](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jeremy11](https://community.auth0.com/u/jeremy11)\
**Post date:** [September 17, 2017, 11:59pm UTC](https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223/1 "2017-09-17T23:59:32Z")

</div>

I’m working on a SaaS product that will need to allow for multiple tenants. This application will have fine-grained access control (think functions vs roles) and a low chance of a user spanning multiple tenants (User A has access to Company A and B’s data – Think a 3rd party consultant, for example)

The main application is an Angular2 SPA, and the back end is a .NET WebApi2 app. I’ve followed the quickstart documentation([this](https://auth0.com/docs/quickstart/backend/webapi-owin) and [this](https://auth0.com/docs/quickstart/spa/angular2) but modified for the newer HttpClient) for setting both up, and the access token is being sent properly, and claims are being populated. I then wrote some additional owin middleware to connect to the userinfo endpoint, to populate a second identity with that information. However, I’m running into issues where the middleware is failing somewhere, and never making it to the controller.

I’m assuming there is a better way (built in way?) to either retrieve the user information automatically, or cache it once retrieved for subsequent calls? I assume sending the id\_token along with the access\_token is frowned upon since it’s not a scenario covered in the OpenId Connect spec?

I’ve seen mention of the custom Auth0 middleware for owin, but these always seem to be used when it’s an MVC + WebApi application (like [here](https://auth0.com/docs/quickstart/webapp/aspnet-owin/00-intro)). Is this something that is recommended to be used with the sort of setup I have, or is there an alternative?

---

<div class="post-metadata">

**Author:** ![jeremy11](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@jeremy11](https://community.auth0.com/u/jeremy11)\
**Post date:** [September 19, 2017, 6:32am UTC](https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223/2 "2017-09-19T06:32:43Z")

</div>

I was going to try Auth0-ASPNET-Owin-Libs, but it looks like it has disappeared from NuGet. Is this intentional (aka - don’t use it?)

---

<div class="post-metadata">

**Author:** ![jerrie1](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jerrie1/32/5898_2.png) [@jerrie1](https://community.auth0.com/u/jerrie1)\
**Post date:** [September 19, 2017, 7:52am UTC](https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223/3 "2017-09-19T07:52:28Z")

</div>

Yes. Previously the Auth0-ASPNET-Owin package took dependencies on Razor and MVC packages, so, therefore, the need for the Auth0-ASPNET-Owin-Libs package which did not take those dependencies, so it could be used in non-web environments.

But the new Auth0-ASPNET-Owin package also does not have the dependency on the Razor and MVC packages anymore, negating the need for Auth0-ASPNET-Owin-Libs

You can just use Auth0-ASPNET-Owin

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [March 2, 2018, 5:56am UTC](https://community.auth0.com/t/properly-setting-up-net-webapi-using-owin-for-multi-tenants/8223/4 "2018-03-02T05:56:33Z")

</div>


