c# - How to detect that IsOneWay is set to true -
as follow below question, i'm getting same error. detect i'm in 1 of these situations, , avoid access servervariables collection. right i've got code in try catch - there has better way it.
[operationcontract(isoneway = true)] public void somefunction() { }
some code called:
protected string getwebclientipaddress(httpcontext context) { try { string ipaddress = context.request.servervariables.allkeys.contains("http_x_forwarded_for") ? context.request.servervariables["http_x_forwarded_for"] : null; if (!string.isnullorempty(ipaddress)) { string[] addresses = ipaddress.split(','); if (addresses.length != 0) return addresses[0]; } return context.request.servervariables.allkeys.contains("remote_addr") ? context.request.servervariables["remote_addr"] : null; } catch (exception ee) { _logger.error("error getting request remote ip", ee); return "error getting remote ip: " + ee.message; } }
original question: httprequest.servervariables throws argumentexception in wcf iis7
Comments
Post a Comment