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

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -