views:

100

answers:

3

Hi there,

I have two domains for example www.male.com and www.female.com which both point to the same website app. In this app I have an HTTP module which checks if the session of the user is still active and if so checks if the user is a male or female.

I want to check from which domain the user entered the website. If the user is a male but entered (came from) www.female.com, the user must be redirected to www.male.com. The opposite must be done in case of a women.

Other scenario's are:

  • a male user enters www.female.com/articles/test.aspx, it should be redirected to www.male.com/articles/test.aspx

  • a male user enters test.female.com/main/default.aspx, it should be redirected to test.male.com/main/default.aspx.

I am using ASP.NET 3.5 on a IIS 7.0 box.

Gr

Martijn

A: 

for the browser it doesnt matter if its the same server the domain is important. you can either open male.com in an iframe to check cookie or set cookie for both domains. or keep track of users using their ip but i wouldnt advise that.

n00b32
and im beginning to feel i misunderstood the question
n00b32
+1  A: 

You can use the Request.Url.Host to determine which site they're on (male.com or female.com), then use Response.Redirect to direct them to the correct site. You can use the other properties on Request.Url to determine the exact path the user is viewing.

chrissr
Good points. Thanks!
Martijn B
Does that answer your question or is there another aspect I can help with?
chrissr
A: 

The simplest way would be to have a common session server that both sites could use a session id to get user information. This way a login on female.com could generate the session data, recognize a male user and then pass the page on to male.com with a query string containing a footprint and a session id (and a short ttl on the transfer). Then male.com could recognize the query string data, parse it, verify it and quickly access the session data.

Joel Etherton
Why should I use the query string for passing data. It is the same application. I didn't take account the fact that a session is bound to a domain or am I wrong on this?
Martijn B
@Martijn B: The session is bound to a process actually, and each website is run under a separate process. Unless you use a separated state server and provide a custom element to allow multiple domains to access a common session you'll have data transfer issues. They may be the same application name and application pool, but you aren't talking about application settings. You're talking about user settings. These things are kept outside of the application pool, so you'll need to be able to transfer this data between domains. That means a post header or query string.
Joel Etherton
Yes but in my case it is the same website running in the same process. It is just two domains pointing to the same website.
Martijn B
I know. I have the same thing running in a large scale production environment. Even though they look like they're running in the same process, they aren't. They spool up separate instances of w3wp.exe in order to maintain separate state. Other than full application variables, there is no real memory sharing between them. The Request.Url properties mentioned in the accepted answer are kept in the header. It's an alternative method of "posting".
Joel Etherton
Not what I expect at all. I will contact my hoster for this. Thanks!
Martijn B