How to make sure HTTP request is local when using HttpListener
HttpListenerRequest
has a property IsLocal
that should contain this information as well. However, it returns false
on my computer. Mirroring the original code, it seems that it has something to do with the property IsLocal
using the code:
return this.LocalEndPoint.Address == this.RemoteEndPoint.Address;
when possible, it should use code in a property (not available) InternalIsLocal
that:
return this.LocalEndPoint.Address.Equals(this.RemoteEndPoint.Address);
(This expression returns true
for my situation). Using this approach may be preferable so that your code does not depend on IPv4 address since the transition is made to IPv6.
source to share