3.3Setting the Request Address
Created on Aug 17, 2026~3 min read
In the static methods provided by the HttpRequestBuilder type, you can configure the request address. The following shows how to use the static methods of the HttpRequestBuilder type to define different request addresses:
// Using a full URL addressHttpRequestBuilder.Get("https://furion.net/");// Using a relative address (without a leading slash)HttpRequestBuilder.Get("api/get/user");// Using a relative address (with a leading slash)HttpRequestBuilder.Get("/api/get/user");// Request address is an empty stringHttpRequestBuilder.Get(""); // string.Empty can also be used instead// Request address is nullHttpRequestBuilder.Get(null);- When the provided request address is a full
URL, it is used directly as the final request address. - If the request address is a relative address (whether or not it includes a leading slash
/), the framework attempts to combine it with theBaseAddressconfigured on theHttpClientto generate the final request address (RFC 3986). For example:
services.AddHttpClient(string.Empty, client =>{ client.BaseAddress = new Uri("https://furion.net/");});In the configuration above, if the request address is "api/get/user" or "/api/get/user", the final request address will be "https://furion.net/api/get/user".
- If the request address is an empty string or
null, theBaseAddressconfigured on theHttpClientis used directly as the final request address. This means that ifBaseAddressis"https://furion.net/", the final request address will also be"https://furion.net/".