簡體   English   中英

如何將呼叫者IP添加到Webget UriTemplate參數

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM