Google News
logo
ASP.NET - Interview Questions
What's the HTTPContext object? How can you access it within a Controller?
HTTPContext encapsulates all HTTP - specific information about an individual HTTP request. You can access this object in controllers by using the ControllerBase.HttpContext property:
public class HomeController : Controller
{
  public IActionResult About()
  {
      var pathBase = HttpContext.Request.PathBase;

      ...

      return View();
  }
}
Advertisement