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!

2 Answers 2

2

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
1

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.

2
  • 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 ? Aug 21, 2009 at 2:17
  • 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
    Aug 21, 2009 at 2:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.