One application... multiple domains

G

Guest

I am developing an application using ASP.NET 2.0. In this application, I need
to provide customized database-driven interfaces based on the domain name
that the user is accessing the application from. A list of these domains will
be avialable in a data table.

What is the most efficient way to determine which domain the application
should respond for each time a page is requested.

It would seem that executing a SQL query each time a page is requested would
be overkill... is there a better way to do this? I'm assuming there must be,
since applications like dotnetnuke can display different content for multiple
domains...

Thanx
 
G

Guest

I would load your domain list into cache, like an array, etc. You can query
against the cached list which will be very fast. I do not know how often
your domain list changes, but you can keep it in cache for limited time, or
even setup a SQL Server callback to reset the cache if you are in 2005. I
have not done this yet, so you are on your own here.
 
J

Joshua Flanagan

How are you using the word "domain"? Do you mean Windows Domain - as in
a Domain Controller? In this case, you should be able to get the domain
name which is prefixed on the user's name (Page.User.Identity.Name) if
you have Windows Authentication enabled on the website (and anonymous
access disabled).

You then write logic to show different interfaces based on that domain
string.

You could even write a custom RoleProvider which uses the person's
domain name to determine their role. That way you could take advantage
of the role-based security built into the new ASP.NET 2.0 sitemap and
Navigation controls. That would allow you to declaratively decide which
navigation links will be displayed to each domain. For more info on role
based site navigation, check out this article:
http://weblogs.asp.net/scottgu/archive/2005/11/20/431019.aspx

For help writing a custom RoleProvider, you can download my Visual
Studio template from here:
http://flimflan.com/blog/ASPNETRoleProviderVisualStudioTemplate.aspx

Just fill in the code for GetRolesForUser() to return the user's domain
name. Something like this:

public string[] GetRolesForUser(string username){
int domainPos = username.IndexOf('\');
string domain = String.Empty;
if (domainPos > 0) {
domain = username.SubString(0, domainPos);
}
return new string[] { domain };
}


Joshua Flanagan
http://flimflan.com/blog
 
G

Guest

Well.... by "domain", I mean domain name, which I don't believe is the same
as a domain controller (right?). This is an application designed for public
(anonymous) users, and will not be using Windows Authentication.

Ryan
 
J

Joshua Flanagan

Yes, a domain name is different from a domain controller. And an
internet domain name is very different than the Windows domain name that
I was thinking of.

If you want to know the internet DNS host name that the user entered in
their address bar, try:

Request.Url.Host
 

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

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top