I tried adding the following one-liner to output the reverse DNS lookup:
@System.Net.Dns.GetHostEntry(Request.HttpContext.Connection.RemoteIpAddress)
But it only returns the GetHostEntry function output.
I only need this oneliner to put in a if-clause which is the recommended method to detect a Googlebot.
Without more context, I am not sure I completely understand. If you wanted to know if the
RemoteIpAddressis coming from Google using a "one-liner" you are almost there. Something like this works for meThat IP address is also the known Google Bot IP address. I hope that helped but again I was not sure the exact question you are asking.
One other thing to take note of is if you sit behind a proxy you will need to add something like the following to make sure the headers are correct.