Best practice for multiple "companies" in one database/site

G

Guest

Hello,

I have a large commerce app, hosted for several hundred companies (i.e. each
"company" is a small business selling something through my site, independent
of all the others).

Each company has a unique ID (e.g. 12345), which is a primary key in the
tables for products, customers, etc. That key also identifies
company-specific customization of my site, such as text strings, various
styles, etc.

I am hosting the app for all customers from a single site and with a single
database. The end customers come to my/my customer's site in one of three
ways: 1) via me.com/myCustomer or 2) via myCustomer.me.com or 3) via
myCustomer.com.

Given all that, here's my question: When a customer comes in via one of the
three ways, how do I then map that to the url I really want, e.g.
me.com?CompanyID=12345? (I have a table that associates the entry point with
the actual ID)

I think it might involve url rewriting, but I've not done that, and there
might be better ways. Any "best practice" thoughts from similar situations
are appreciated.

tia,

Bill
 
K

Kevin Spencer

Hi Bill,

It's really a simple matter of redirecting with a QueryString. Of course,
I'm assuming that you do have a method in place that identifies the Comany
ID of the company.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living
 
K

Karl Seguin

I agree with your assessment that URL Rewriting would be the way to go. I
wrote a bit about it at:
http://openmymind.net/localization/index2.html#urlrewrite

it's with respect to cultures, but you should be able to use it for your own
needs.

The basic idea is on Begin_Request you figure out the customer id (via your
association table) and simply do a
Context.RewritePath("index.aspx?CompanyId=" + CompanyId.ToString());

Karl
 
G

Guest

Good stuff, thank you both. I'm closer to understanding, but still don't get
some basics.

For one, *where* does this interception happen? I picture it like this: I
try to go to www.domain.com, IIS looks down its list, finds default.aspx, and
loads it up, which if this is the first time in then spins up the app. Where
in there am I saying "don't really go find default.aspx, find something
else"? I understand the custom httpModule, but where does *it* live and how
am I telling all the different entry points to always go there so it can do
its mapping?

And, is anything different when I go to subdomain.domain.com vs.
domain.com/folder? In the subdomain case, don't I need an app sitting there
at each subdomain location, or do I handle the mapping at a higher location
(DNS all pointing to the same spot?)?

Bill
 
H

Hans Kesting

And, is anything different when I go to subdomain.domain.com vs.
domain.com/folder? In the subdomain case, don't I need an app sitting
there at each subdomain location, or do I handle the mapping at a
higher location (DNS all pointing to the same spot?)?

For the "folder" situation, it might be best to add a "404.aspx" page to IIS.
If the folder doesn't exist, then IIS normally gives a 404 error, without
activating your application (an httpmodule there will not be called).
By handling that 404 with a page that lives inside your application, you
can do your own redirecting there.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top