Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get URI from which REST API (ServiceStack) being consumed

I have some issue regarding REST API which i have built using servicestack. End user will consume this API from their application hosted on their server. I'd like to grab absolute uri and IP address from which this REST API being consumed.

When i am doing testing it locally as per below then it gives me URL of REST API itself instead of application from where it is consuming.

 string str = RequestContext.AbsoluteUri.ToString();

Please how can i get details about source from where my REST API is consuming.

Thanks in Advance.

like image 738
Arun Rana Avatar asked Dec 05 '25 05:12

Arun Rana


1 Answers

I'm not sure I understand this question correctly, do you want the referrer url? or physical location path? Either way the Original ASP.NET request object should have all the information you need which you can access in your webservice with:

var aspnetReq = (HttpRequest)RequestContext.Get<IHttpRequest>().OriginalRequest;

Which you can use to access all information about the request.

like image 179
mythz Avatar answered Dec 07 '25 20:12

mythz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!