C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » .NET Framework »

Some Useful and Efficient .Net commands


Posted Date: 29 Mar 2005    Resource Type: Articles    Category: .NET Framework
Author: SattyMember Level: Gold    
Rating: 1 out of 5Points: 5



Retrieving Machine Name:


This is one of the questions which is frequently asked by the beginners.The easiest way to retrieve a machine name is by using the command given below.

string strServer = System.Environment.MachineName;


The next way of retrieving the Machine name is by using the DNS name.

using System.Net;
string hostname = Dns.GetHostName();



Checking Browser:


The next frequently asked question is to find the browser name on which the end user works.Some sites are specifically built to work on IE alone.So if the programmer wants the user to open using IE and not with other browsers, he can restrict the user by the below given command.

browser = Request.Browser.Browser.ToString();
if (browser !="IE")
{
Response.Redirect("Redirect.aspx");
}


Getting IP Address using DNS:


The next question among the beginners is to get the IP Address.The IP Address can be retrieved using several ways by using REGISTRY,WMI,DNS.The code which is given below explains the retrieval of IP Address using DNS.


Getting the Machine Name:
string mcName =Dns.GetHostName();
IPHostEntry addressall = Dns.GetHostByName(mcName);
foreach(IPAddress ipaddress in addressall.AddressList)
{
Response.Write("IPAddress = " + ipaddress.ToString());
}




Summary


This article is written to help the beginners of ASP.Net who wnats to know the basics and use it effectively in their program and if u have any questions feel free to contact.

Thanks
Satty



Responses

Author: Sachin B.    01 Apr 2005Member Level: Bronze   Points : 0
Thank you very much Satty.
This article is very usful for the beginners like me
If possible do post more articles.
Thanks again.

With regards,
Sachin



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to secure data using cryptography
Previous Resource: Learn how to develop and run .Net Applications on Linux and UNIX
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use