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.32k stars 267 forks source link

IIS Express Issue #141

Closed pkavan closed 5 years ago

pkavan commented 5 years ago

I like to use IIS Express during development as I deploy to IIS. However, that is always a little tricky with multi-tenant. SaaSKit resolves differently -- and I resolve using a DB -- so the host entries are stored there just differing ports, not with a subdomain.

With Finbuckle, I assume I need to modify the hosts file and perhaps do something with project properties. Do you have an example of what you've done?

Thanks.

pkavan commented 5 years ago

I did manage to get it working for one tenant, when I try to navigate to the other, I get:

HTTP Error 400. The request hostname is invalid.

AndrewTriesToCode commented 5 years ago

hi again @pkavan IIS Express is very tricky to get working using subdomains. I've used the host strategy successfully in IIS deployments, but always had trouble with IIS Express in development. I use macOS mainly though so it isn't a problem I run into. I don't think its Finbuckle.MultiTenant specific though.

Taken from here: Find this file in your solution folder: .vs\config\applicationHost.config

and edit it like so (using whatever port and tenant subdomains you want to work):

<bindings>
   <binding protocol="http" bindingInformation="*:5252:localhost" />
   <binding protocol="http" bindingInformation="*:5252:tenant1.localhost" />
   <binding protocol="http" bindingInformation="*:5252:tenant2.localhost" />
   ... etc
</bindings>

If you are using IIS Express 10 I think you can use a wildcard that covers all cases: <binding protocol="http" bindingInformation="*:5252:*.localhost" />

Edit:: I think you have to run Visual Stuidio as Administrator for this to work

AndrewTriesToCode commented 5 years ago

@pkavan Hi, did you ever have success getting this to work with IIS Express?

pkavan commented 5 years ago

Sorry, I have been busy with other projects and then a week and a half of a much needed vacation -- so I am just getting back to this today. I will let you know how it goes.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

vdecristofaro commented 4 years ago

I use macOS mainly though so it isn't a problem I run into.

How did you configured this on a mac? Thanks

AndrewTriesToCode commented 4 years ago

@vdecristofaro on Mac you can edit your /etc/Hosts file and add entries for your local hosts files to have your subdomains point to your loopback address. This link explains how to do it:

https://www.imore.com/how-edit-your-macs-hosts-file-and-why-you-would-want

After 127.0.01 localhost you can have lines like:

127.0.0.1    tenant1.localhost
127.0.0.1    tenant2.localhost