c# - How do you get the User's IP Address in Castle MVC (Monorail)? -


in controller action of castlemvc application, how can user's ip address?

i think in asp.net mvc request.servervariables["remote_addr"], can't find equivalent in castle.

(i aware of potential proxy issue's etc, address reported in request fine)

castle monorail, asp.net mvc, serve elegant mvc skin on asp.net runtime.

as such, can done asp.net runtime (except webforms specific stuff viewstate) can done asp.net mvc , monorail.

so, can grab current asp.net's httpcontext using static httpcontext.current method.

from monorail, can use ienginecontext's .underlyingcontext property access asp.net httpcontext.

specifically, in monorail, can grab client's reported ip using convenience property userhostaddress on current irequest.

e.g. within controller's action:

var clientip = request.userhostaddress; 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -