views:

217

answers:

2

This question is similar to this: Asp.net Profile Across Sub-Domain

I'm basically wondering if a user logs in through "www.yourdomain.com", is it possible for "subdomain.yourdomain.com" to also recognize them as logged in by checking their AuthCookie?

The referenced question's answer is to put: domain="yourdomain.com" within your web.config.

My question is how do you set this up to work locally when your domain is localhost? Do you just take domain out on your local/dev environment?

Any help with this would be much appreciated.

Thanks!

+1  A: 

Well, localhost is just a local DNS entry for 127.0.0.1.

If you edit your c:\windows\system32\drivers\etc\hosts file, you can add other entries such that it matches your live environment (but, obviously, it will mean that all requests for those domains will go to your local machine, not the real servers).

If you're talking about managing configs across different deployments of your app (local, dev, release) then you need to look at doing some post-build tasks.

Noon Silk
I can handle the multiple configs based on machine, so that's not a problem. So are you suggesting, at least for testing purposes on my local machine to change my hosts file to read 127.0.0.1 yourdomain.com ?
Jack Marchetti
Well, only if you can't change your configs to deal with it appropriately. I'm saying that doing that may cause you issues because you won't be able to get to the live site normally. At worst you could do '127.0.0.1 local.yourdomain.com' and then make the appropriate config changes.
Noon Silk
+1  A: 

I actually just coded something up like this in the last hour. I used httpCookies in Web.config although setting the domain on the forms authentication tag works also.

Here's what I set in web.config:

<httpCookies domain="thedomain.com" />

Here's what I added to my hosts file:

127.0.0.1       local.thedomain.com

Then when I access the site on my dev box I browse to:

http://local.thedomain.com
Mike Knowles