[英]how to add the caller IP to a webget UriTemplate parameters
我找不到在uri模板參數中添加到Web的方法。
我要使用RESTful服務,並且需要在GET操作中添加調用方IP,以便在接口實現中使用。
我希望有一個用於此目的的關鍵字,例如“ context.Request.UserHostAddress”,並且以下屬性將起作用:
[WebGet(UriTemplate = "?{context.Request.UserHostAddress})]
找到了!
您需要在實現中添加以下內容:
var clientIp = OperationContext.Current.IncomingMessageProperties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty??new RemoteEndpointMessageProperty("",0);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.