TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
ashish saxena
NA
2
7.4k
How to get the computer name and IP address
Dec 6 2013 12:17 AM
protected void btnSubmit_Click(object sender, EventArgs e)
{
//var ip=HttpContext.Current.
//var host = HttpContext.Current.Request.UserHostName.Trim();
//txtIPs.Text = host.ToString();
//var host = System.Web.HttpContext.Current.Request.LogonUserIdentity.Name.ToString();
//txtIPs.Text = host.ToString();
//string strDNS = Dns.GetHostName();
//string aa = System.Security.Principal.WindowsIdentity.GetCurrent().User.ToString().Trim();
//string bb = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Substring(5).ToString().Trim();
//txtIPs.Text = bb;
//DNSLookup(txtDomain.Text);
//string ip = txtIPs.Text;
//string str = Server.HtmlEncode(Request.UserHostAddress);
//txtIPs.Text = str;
string strHostName = string.Empty;
strHostName = Dns.GetHostName();
IPHostEntry ipEntry = Dns.GetHostByName(strHostName);
IPAddress[] addr = ipEntry.AddressList;
for (int i = 0; i < addr.Length; i++)
{
txtIPs.Text = ("IP Address " + i + addr[i].ToString() + ", HostName: " + strHostName);
}
SqlConnection con = new SqlConnection(ConfigurationManager.AppSettings["ConStr"]);
SqlDataAdapter da = new SqlDataAdapter("Insert Into pew(name,ip)values('"+txtName.Text+"','" +txtIPs.Text+ "')", con);
DataSet ds = new DataSet();
da.Fill(ds);
lblStatus.Text = "Data Successfully Inserted";
txtName.Text = "";
txtIPs.Text = "";
}
HELLO SIR , I M FACING SOME PROBLEM,ACTUALLY I GOT THE COMPUTER NAME AND IP ADDRESS IN PARTICULAR SYSTEM WHERE DID I IMPLEMENT THE CODE, WITH THE HELP OF THIS CODE ITS PROPER
WORKING BUT AFTER HOSTING THE WEBSITE IN IIS SERVER, IT'S DISPLAY THE COMPUTER NAME AND IP ONLY THE SERVER . WHILE I WANT TO THAT I FORWARD THE LINK TO SOMEONE THAN I GOT THE IP AND COMPUTER NAME HIM/HER . PLEASE HELP ME, ITS VERY URGENT ITS FEEDBACK FORM ,IF ANY ERROR IN THIS CODE THAN PLEASE CORRECT THIS AND SEND TO ME ...
Reply
Answers (
2
)
regarding asp.net mvc telerick controls
Why .net 4 website does not run smoothly in IE 11?