0

I have a project that is written on the top of Asp.NET 5/Core using Visual Studio 2019.

My project has multi-tenancy support and need to be able to map multiple local domains to the project to test out multi-tenancy.

How can I bind a second local domain to point to the same running host? I added tenant1.website and tenant2.website in the .hosts file like so

127.0.0.1     tenant1.website
127.0.0.1     tenant2.website

I tried to modify the .vs\PrjectName\config\applicationhost.config and added new binding like this

 <site name="ProjectName.Web" id="2">
        <application path="/" applicationPool="ProjectName.Web AppPool">
          <virtualDirectory path="/" physicalPath="E:\ProjectName\ProjectName.Web" />
        </application>
        <bindings>
          <binding protocol="http" bindingInformation="*:37893:localhost" />
          <binding protocol="https" bindingInformation="*:44356:localhost" />

          <binding protocol="http" bindingInformation="*:37893:tenant1.website" />
          <binding protocol="https" bindingInformation="*:44356:tenant1.website" />

          <binding protocol="http" bindingInformation="*:37893:tenant2.website" />
          <binding protocol="https" bindingInformation="*:44356:tenant2.website" />

        </bindings>
 </site>

But, when I go to https://tenant1.website:44356 I get the following error

This site can’t be reached

How can I correctly bind tenant1.website and tenant2.website to my locally running app using IIS Express?

Jay
  • 1,168
  • 13
  • 41
  • When you go to `https://tenant1.website`, do you use port 44356 as specified in your bindings? e.g. `https://tenant1.website:44356` – Paul Suart Nov 09 '21 at 20:09
  • @PaulSuart yes I get this `tenant1.website` can't be found – Jay Nov 09 '21 at 20:12
  • We have a similar set-up. The only other thing we do that you're possibly not doing is to set the `Project Url` on the "Web" tab of the web project's properties (right click web project > Properties). – Paul Suart Nov 09 '21 at 20:23
  • Checked my local setup for this - I use `tenant1.localhost` not `tenant1.website` - could be part of it too. – Paul Suart Nov 09 '21 at 20:28
  • I can't find the where to set the `Project URL` from inside the properties. This is an asp.net core app not asp.net mvc. I'll try to change the host – Jay Nov 09 '21 at 20:31
  • Is `launchSettings.json` still a thing for asp.net core sites? – Paul Suart Nov 09 '21 at 20:39
  • it sounds like it but not sure how to really get it working https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/development-time-iis-support?view=aspnetcore-6.0 – Jay Nov 09 '21 at 20:55
  • I saw that too. Sorry I can't help more. – Paul Suart Nov 09 '21 at 20:57

0 Answers0