To get the base URL in an ASP.NET MVC application, you can use the following approach:
Using Request.Url in the Controller:
var baseUrl = Request.Url.GetLeftPart(UriPartial.Authority);
This retrieves the scheme (HTTP/HTTPS), hostname, and port from the request URL.
Using Url.Content for Relative Paths: Combine the base URL with a relative path using:
var fullUrl = baseUrl + Url.Content("~");