Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Get Server Domain in ASP.NET

Posted on 2003-02-28
10
Medium Priority
?
616 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
  • 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
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database

 

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

Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

Question has a verified solution.

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

Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month15 days, 21 hours left to enroll

580 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