?
Solved

Get Server Domain in ASP.NET

Posted on 2003-02-28
10
Medium Priority
?
615 Views
Last Modified: 2012-06-27
Does anybody help me with a line of VB.NET code to ascertain the domain a server is running on.
0
Comment
Question by:ChiefDamon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
10 Comments
 
LVL 1

Expert Comment

by:SeanGraflund
ID: 8043807
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
 

Author Comment

by:ChiefDamon
ID: 8044750
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
 
LVL 1

Expert Comment

by:SeanGraflund
ID: 8057145
in a class module you can get it using

HttpContext.Current.Request.ServerVariables
0
Automating Terraform w Jenkins & AWS CodeCommit

How to configure Jenkins and CodeCommit to allow users to easily create and destroy infrastructure using Terraform code.

 

Author Comment

by:ChiefDamon
ID: 8057644
Is there a particular import I need to make in the class header to reference HttpContext?
0
 
LVL 1

Expert Comment

by:SeanGraflund
ID: 8057659
I think it's System.Web
0
 

Author Comment

by:ChiefDamon
ID: 8058248
Is there a particular import I need to make in the class header to reference HttpContext?
0
 

Author Comment

by:ChiefDamon
ID: 8058287
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
 
LVL 1

Accepted Solution

by:
SeanGraflund earned 400 total points
ID: 8058368
try just using System.Web.HttpContext.Current.Request.ServerVariables
0
 

Author Comment

by:ChiefDamon
ID: 8058436
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
 
LVL 1

Expert Comment

by:SeanGraflund
ID: 8058447
cool, glad i could help
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question