Get Server Domain in ASP.NET

Does anybody help me with a line of VB.NET code to ascertain the domain a server is running on.
ChiefDamonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SeanGraflundCommented:
Request.ServerVariables("SERVER_NAME") = name of machine
Request.ServerVariables("HTTP_HOST") = domain

Example:

machine name: webtest (the name of the machine on the network)

domain name: webtest.mycompany.com (the domain name of the machine)
0
ChiefDamonAuthor Commented:
Actually I need to determine the server domain from within a .net class module.  You code works and I could add it as a parameter to the methods but I call it in about 100 different web pages and the application is rolling to the production server next week.  Any suggestions?
0
SeanGraflundCommented:
in a class module you can get it using

HttpContext.Current.Request.ServerVariables
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

ChiefDamonAuthor Commented:
Is there a particular import I need to make in the class header to reference HttpContext?
0
SeanGraflundCommented:
I think it's System.Web
0
ChiefDamonAuthor Commented:
Is there a particular import I need to make in the class header to reference HttpContext?
0
ChiefDamonAuthor Commented:
I had add the reference manually using the add reference menu, but still I was unable to get any code to execute without error.  The code is simple enough to use in a aspx page but does anyone have a example of this code in a class module?
0
SeanGraflundCommented:
try just using System.Web.HttpContext.Current.Request.ServerVariables
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ChiefDamonAuthor Commented:
Yes!  That worked fine.  I have to add the reference manually but cannot put an imports statement in.  The imports seems to screw everything up.
Thanks.
0
SeanGraflundCommented:
cool, glad i could help
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.