1

Closed

Cannot test multi-tenant site on local machine

description

The instructions on the page

Setting Up a Multi-tenant Orchard Site

Are as follows:

"The Add New Tenant screen asks for the name of the tenant (which should not contain any spaces, by the way), and the host domain that will map to the tenant. If you are running locally and don't have a domain to map, you can edit your \Windows\System32\drivers\etc\hosts file to create a sample host. Alternatively, you can use *.127-0-0-1.org.uk, where * is the name of your tenant or another name of your choosing. This will loop back to localhost and is sufficient for testing multi-tenancy locally."

I’m afraid I’m having trouble with either of the mentioned options. To me this statement is quite vague and could do with a concrete example.

For a new tenant ‘mydemo’ I want to add to:

http://localhost:51642/Admin/MultiTenancy I have added this line to my hosts file: 127.0.0.1 mydemo

and I have configured the new tenant:

http://mydemo:51642/ But all I get is HTTP 400 Bad Request.

I installed Orchard 1.0.2 from WPI and running from WebMatrix on Windows 7, running IE9 beta. I’m using Compact DB for default tenant and the new tenant...

Email reply from Bertrand Le Roy advised:

"Can you try to restart your web server after creating the tenant? We found that this could make it work."

Unfortunately, neither restarting the site nor the machine fixes this for me.
Closed Jan 27, 2011 at 10:18 PM by BertrandLeRoy
See comments

comments

filetek wrote Jan 16, 2011 at 12:11 PM

By default using WebMatrix/IISExpress will only match/listen to one host name [localhost] on the specified port 51642 for the web site/application.

You need to add extra bindings to the config file to include your new Tenant/Host [mydemo].

Edit "C:\Documents and Settings\Your Name\My Documents\IISExpress\config\applicationhost.config".

Find configuration details for Orchard in node sites then site Name="orchard".

In bindings there should only be one binding node as follows:

binding protocol="http" bindingInformation="*:51642:localhost"

Add a second with the new Tenant/Host name

binding protocol="http" bindingInformation="*:51642:mydemo"

When you start your site in WebMatrix it will only show a single binding [usually the last] on the site page but if you click on the IISExpress Icon in the SysTray the Menu will show multiple urls associated with the orchard site.

I have a system working on XP with 3 Tenants setup, but I also took the additional steps of creating a separate IP address for IISExpress to bind to so that I can use port 80 [needs administrator priviledges] for all development web sites without the need to use port numbers in urls.

You will still need to setup your default web site, install and enable Multi Tenancy, and then stop and restart the web site before you add any new Tenants to initialise the application fully with Multi Tenancy.

Looking at the code a Tenant Name of "mydemo" and Host "mydemo" or "mydemo:51642" should work - when I added the http:// and / as suggested the application duplicated them and would not match the new Tenant.

rohancragg wrote Jan 22, 2011 at 11:29 AM

Thanks for the reply.

I have tried what you suggest but it still does not work.

I suspect the reason it does not work is that I'm running on Win7 rather than XP.

URL binding failure

Cannot start the website because administrative privileges are required to bind to the hostname or port.

Recommendations:
  1. Replace "hostname" with "localhost".

In the log file I get this:

Successfully registered URL "http://localhost:51642/" for site "orchard" application "/" Failed to register URL "http://mydemo:51642/" for site "orchard" application "/". Error description: Access is denied. (0x80070005)

BertrandLeRoy wrote Jan 27, 2011 at 9:47 PM

Can you try this with the full IIS?

BertrandLeRoy wrote Jan 27, 2011 at 10:18 PM

IIS Express allows this. Unfortunately, Windows restricts the URLs that are being used (e.g. http://myhost:51642/).

If you are an admin, you can set your machine up to eliminate the restrictions. There are a couple of articles we have that explain this:

http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/
http://learn.iis.net/page.aspx/1003/running-iis-express-without-administrative-privileges/

rohancragg wrote Feb 12, 2011 at 9:53 AM

OK, I finally got this working. Thanks Bertrand for the links. Here's how to do it:

[Assuming you are using Windows 7 - probably similar for Vista...]
[Please substitute 'mydemo' for your site name - also works for a fully qualified domain name such as mydemo.co.uk]

Open the folder c:\Windows\System32\drivers\etc\
Right-click on the hosts file and give yourself modify permissions to that file.
Open hosts file in a text editor
Add the line:
127.0.0.1    mydemo
Open the folder C:\Users[YourUserName]\Documents\IISExpress\config\
Open applicationhost.config in a text editor
Locate the section for your existing Orchard Site (assumes you've been working on one in WebMatrix), e.g.
<site name="mydemo"...
Under the <bindings> section, leave the default localhost binding, but copy it onto the next line and edit it to read:
<binding protocol="http" bindingInformation="*:28923:mydemo" />
(substitute the port number above for the one you copied from the default localhost binding)

Open WebMatrix with admin privileges (Ctrl-right-click on the program shortcut and select 'Run as Administrator')

Open your site and attempt to start it.

Locate the IIS Express icon in the taskbar and right-click on it.
You should see your site name where you can select to open it via it's additional URL.

Remember to remove the item from the hosts file (or comment out the line using the # character), if you want to view the live site from the same domain name (once you've deployed it to an ISP).
Even so I think you need to be very careful that you are sure you're looking at the remote site rather than the local one - consider adding something to one or other of the themes to make the difference immediately apparent!

rohancragg wrote Feb 12, 2011 at 7:51 PM

Correction to previous advice...

If you don't want to run WebMatrix with admin privileges then you need to use the step(s) in the article "Handling URL Binding Failures in IIS Express":
http://learn.iis.net/page.aspx/1005/handling-url-binding-failures-in-iis-express/

In the case of this example you will need to execute a command promp with admin privileges and then execute the command:
netsh http add urlacl url=http://mydemo:28923/ user=everyone

This can later be removed with:
netsh http delete urlacl url=http://mydemo:28923/

fugees wrote Jun 12, 2011 at 5:17 PM

i set up this module follow the doc walkthrough,but failure.can you help me?
  1. i modify the host file in system32/drivres/etc,i added the line: 127.0.0.1 newstar
  2. i modified the applicationhost.config file in iisexpress config dictionary。the node like this:
    <site name="newstar" id="2">
            <application path="/" applicationPool="Clr4IntegratedAppPool">
                <virtualDirectory path="/" physicalPath="%IIS_SITES_HOME%\Orchard CMS" />
            </application>
            <bindings>
                <binding protocol="http" bindingInformation="*:37611:localhost" />
                <binding protocol="http" bindingInformation="*:37611:newstar" />
            </bindings>
        </site>
    3.run the webmatrix as administrator,the IIS Express icon in the taskbar i found two url
    http://localhost:37611 http://newstar:37611 4.select the url http://newstar:37611 to open the orchard dashborad, set up a multi-tenant 5.i add the tenant named samliy,then save.the tenant url like this: samliy - http://samliy.newstar:37611/
    6 then click set up,occur error.
    Can not establish connection to the server samliy.newstar:37611
please help me .