Question: ```
HttpClient client = new HttpClient(); 
client.BaseAddress = new Uri("http://localhost:60792"); 

```

Instead of localhost:60792 how do I find it dynamically on start up? Pointing me in the right direction would suffice. But if you have an answer let me know. 

Update thanks for the hint. My final answer is
==============================================

```
String baseURL = string.Format(
      (
        System.Web.HttpContext.Current.Request.Url.Port != 80) ? "{0}://{1}:{2}" : "{0}://{1}",
        System.Web.HttpContext.Current.Request.Url.Scheme,
        System.Web.HttpContext.Current.Request.Url.Host,
        System.Web.HttpContext.Current.Request.Url.Port
);

```

Answer: 
`string url = HttpContext.Current.Request.Url.AbsoluteUri;`
After the new update of Visual studio 2019 the answer by @webNoob will give an error

`'HttpContext' does not contain a definition for 'Current' and no accessible extension method 'Current' accepting a first argument of type 'HttpContext' could be found (are you missing a using directive or an assembly reference?)`

So even though you use `System.web` and `System.Net.Http` you will get the same error.

Still you can use the following as a fix:

For getting query of the string 

1. For getting the query
`var url1 = HttpContext.Request.Query.Keys;`
2. For getting the path
`var url2 = HttpContext.Request.Path.Value;`