Alex Rivera | Logout

How to get server domain name

Asked 2009-10-21T14:23:39.807
11

Can anybody tell me how to get servers domain name in asp.net? (Environment.UserDomainName returns "IIS APPPOOL" string)

Thanks for replays, but mostly they are about DNS name of the server, what I need is the domain name. For example when I login via windows authentication I type domain\user and I need this "domain"

Edit
Report

1 Answer

2

There is specific problem to your question, there may be more than one domain name for a specific IP address.

As Tinister stated, you can use

HttpContext.Current.Request.Url.Host

But that will only tell you what the user wrote in the address bar of the browser. If the user added an entry to their host file for your site, and then use that host name, that is what you will see. (I have no idea why they would do so).

If you have more than one domain name for your web site, you can use that to figure out which of the domain names that the user requested.

answered 2009-10-21T14:41:10.327

Your Answer