开发者

Multiple domains, same application but different result on each subdomain. how to keep track of which account for the subdomain?

I have a web application where users can register. Each user will get a subdomain to their account. and each subdomain will be kind of unique but use the same web application as every one else.

The application is .net and i run it on a iis 2003 or 2008 (not desided yet.) and I am aiming for about 1000 users. ( 1000 subdomains)

For example:

user1.mydomain.com
user2.mydomain.com
user3.mydomain.com   alias sub.something.com

it is not always possible to get the account ID from the subdomainname as you see bacause of the aliases of the domains.

so I was thinking about different approaches. 1: for every page request a database lookup is performeed and the Id of the account is returned. drawbacks? extra database communication. And the table containing all the domainnames for all the users, e text search in the database every time a page is requested does not sound as a good idea.

2: as number 1, but accountId is saved as session. but what happ开发者_运维知识库ens with 1 thousend accounts, and every account has 1000 viewers, large amount of memory is used??

3:I dont know if this one is possible, but i think its a good one... I was thinking about creating all the subdomains.. User1., user2., user3.... And the alias for each subdomain is saved within IIS. Within each folder for all the domains, i create an ID file. just containing the ID of the user as:

id.aspx
-----
accountID = ##;
-----

And after that i want all the files for the application to be virtual included into each subdomain.

Explanation: Each subdomain contains the following files:

id.aspx
file1.aspx virtual file from web.mydomain.com
file2.aspx virtual file from web.mydomain.com
File3.aspx virtual file from web.mydomain.com
....

and file1...3 is somewhere else on the IIS. Is this possible?

So please, is there someone here that could help me with this problem? What should I do? I Guess this is a common "problem" that many persons have solved in a good whay.

Thanks for your time reading this.

Best Regards Matte


To me, #3 can be challenge from management perspective. I will rather go with approach similar to #2 - your mappings are stored in database. When user logs in, look up is performed and the account id is cached in session state. If you are already using session state for something else then adding this bit information is not really a overhead. Otherwise, you can consider other options for caching this information - for example, it could be put into the cookie (of course you have to add mechanism such as encryption/check-sum to avoid tampering). You can also make account id as part of user identity (by pushing it into authentication cookie which is anyway made tamper-proof by ASP.NET runtime).

Considering that you have 1000 users, I will most probably choose to build in-memory look up table (store the dictionary in ASp.NET cache or static variables), considering 10 aliases per user, it will not have more than 10000 entries - build the table at the time of application start and start of each request, do a look-up and get the account id and store it into HttpContext so that it's available hence forth.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜