I want to get website url into my webapi method. e.g my website name is abc.com and my api method url is xyz.com/getdetails?a=1 now on my webapi controller i want to get abc.com url to identify from this method was called.
You get some complete information along with port on which the api is hosted. But you will need to add System.Web to make it work.
HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath.TrimEnd('/');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With