I need to store the hostname of the requesting computer in the database if a new dataset is created. To clearly indicate this to the user (it’s all company internal), we display this as three textboxes in the form the user fills out.
These three textboxes are filled like that:
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
txtHostname.Text = Request.UserHostName.ToString();
txtIPAdress.Text = Request.UserHostAddress.ToString();
txtWindowsLogin.Text = Request.LogonUserIdentity.Name.ToString();
}
}
However no matter from what client I tested, the reverse lookup of the IP which should give the hostname in Request.UserHostname does not work, so the field is filled with the IP address. If I use nslookup on the server, the reversing works fine.
Any hints for me where I could start?
Thanks a lot.
You need to configure IIS to get this working. Alternately, you can use Dns.GetHostEntry to do the reverse lookup if you only need it in one spot.
Reverse lookup on every request can have a severe impact on performance, which is why it is not enabled by default. I’d recommend the
Dns.GetHostEntryroute if you can.Here’s a helpful reverse lookup method we use: