title: How to check if controller context is child action in ASP.NET Core MVC?
body: <p>I am using .NET Core MVC to prevent users from navigating to an action by manually entering the URL into their browser. </p>
  
  <p>In previous versions of MVC the following code snippet would do the trick:</p>
  
  <pre><code>public ActionResult Index()
  {
      if(!ControllerContext.IsChildAction)
      {
          // redirect to different action
      }
      return View(viewModel);
  }
  </code></pre>
  
  <p><a href="https://stackoverflow.com/questions/9407172/asp-net-mvc-how-to-prevent-browser-from-calling-an-action-method">Source (also similar question)</a></p>
  
  <p>How could I accomplish this using .NET Core MVC? </p>