简体   繁体   中英

how to add the caller IP to a webget UriTemplate parameters

I can't find a way to add to web get in the uri template parameters.

I'm wring a RESTful service and I need to add to the GET operation the caller IP in order to use in my interface implementation.

I would expect the there is a keyword for that purpose something like "context.Request.UserHostAddress" and that the following attribute would work:

[WebGet(UriTemplate = "?{context.Request.UserHostAddress})]

found it!

you need to add to your implementation the followings:

var clientIp = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty??new RemoteEndpointMessageProperty("",0);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM