Question

I am trying to return the users host name (not address) in owin. I am running nancy on top of this. I know I can use this.Request.UserHostAddress to get the IP but I need the name. I have looked through the API's goggled and I ma struggling to find this information.

The only way I can determine to do this is use the ASP.NET HttpContext.Current.Request.UserHostName but this won't work when we self host owin and writing code to determine this information depending on how OWIN is hosted seems to defeat the object of OWIN.

Was it helpful?

Solution

From an IP address, you can use Dns.GetHostEntry (or moral equivalents) to get a IPHostEntry object that has a HostName property.

That's all that UserHostName was doing for you anyway (a DNS lookup):

Gets the DNS name of the remote client.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top