I would like to track client sessions by connection (not session state or cookies) in ASP .NET. I was planning on doing this by using the client's IP address and ephemeral port number.
You can get the IPAddress in ASP .NET via
HttpContext.Current.Request.UserHostAddress
HttpContext.Current.Request.ServerVairables["REMOTE_ADDR"]
.Neither of which give you the reply port number. Is there another way to get it? Is it even possible?
HttpContext.Current.Request.ServerVariables["REMOTE_PORT"].
^^^^
perhaps?
You can't really do this for regular web browsing because HTTP connections between the client and the server are not long lived.
For example IIS7 specifies a default idle timeout of 120s after which the connection will be torn down.
The next time your browser connects to the server the "ephemeral" port number will most likely have changed (because it's chosen randomly).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With