mvc get base url

Code Example - mvc get base url

                
                        Request.Url.GetLeftPart(UriPartial.Authority) + Url.Content("~")
                    
                
 

asp.net core get root url in view

                        
                                FOR ASP.NET CORE:
public WhateverController(IHttpContextAccessor context) //In the constructor
{
  var request = context.HttpContext.Request;
  var _baseURL = %%%~COMPRESS~PRE~1~%%%quot;{request.Scheme}://{request.Host}"; // http://localhost:5000
}