Caputuring (netbios) Server Name in ASP.NET

B

Brad Baker

Using ASP.NET (or classic ASP) is there a way to capture the NETBIOS name of
the server that a page was run on?



Currently we have email based error reports which get sent to us from our
web sites. We have hundreds of websites on half a dozen servers. Sometimes
the same website is load balanced across multiple servers so figuring out
the "origin" of an error can be a challenging.



Right now we do this by examining the email headers of each error report,
and determining which SMTP server the error message originated from.
However we would like to moving away from having errors reported via email
(due to volume) and moving towards storing this information in a database
driven system. One of the caveats of doing this would be having a reliable
mechanism to determine the origin of an error.

I found a way to do this with WMI/vbscript but its CPU intensive and not
practical on a large scale. Two or three hits to the script, drive the
server CPU usage up by 10-20% or more. I'm hoping to find an equivalent way
to do this in ASP.NET which is much more efficient/scalable. Any guidance or
suggestions would be appreciated.

Thank You,
Brad
 
S

Swanand Mokashi

Brad -

There are a few things you can try :

1. Put the server name in the web.config file and grab that information when
you send the email -- however since you have hundreds of server this may not
be an option for you.
2. You can use Server.MachineName to get name of the machine -- that can be
possibly added to your email logic
3. You can use Microsoft Application block for exceptions . It can provide
you with a lot more information when exceptions are thrown.

I think # 2 might be quickest for you right now

HTH


--
Swanand Mokashi
Microsoft Certified Solution Developer (.NET) - Early Achiever
Microsoft Certified Application Developer (.NET)

http://www.dotnetgenerics.com/
DotNetGenerics.com -- anything and everything about Microsoft .NET
technology ...

http://www.swanandmokashi.com/
http://www.swanandmokashi.com/HomePage/WebServices/
Home of the Stock Quotes, Quote of the day and Horoscope web services
 
S

Steven Cheng[MSFT]

Hi Brad,

I agree with Swanand. Actually, it is exposed through the
System.Environment.MachineName Property, the MSDN document has said that
this property return the NetBios name of the local computer:

http://msdn2.microsoft.com/en-us/library/system.environment.machinename(VS.8
0).aspx

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
Joined
Sep 10, 2009
Messages
1
Reaction score
0
ASP.NET C# How to get server name

This days you may try this:

System.Net.Dns.GetHostByName("LocalHost").HostName;


Good luck........




Spiralic.com
webdev.spiralic.co.il

Web development
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top