title: how to inject dependency in _viewimports file
body: <p>I am trying to generate a generic BaseViewPage in asp.net Core to access Current User's Identities.</p>
  
  <p>For this purpose I created a BaseViewPage.cs file  - </p>
  
  <pre><code> public abstract class BaseViewPage&lt;TModel&gt; : RazorPage&lt;TModel&gt;
      {
          private static ClaimsPrincipal principal;
          public BaseViewPage(IPrincipal _principal)
          {
              principal = _principal as ClaimsPrincipal;
          }
      }
  </code></pre>
  
  <p>As you can see in the constructor here I am injecting a dependency of <code>IPrincipal</code> type so that it gets defined at run time. </p>
  
  <p>Now time to inherit it in _viewimports.cshtml file to use current user in all the view pages as below - </p>
  
  <pre><code>@using TWCStore
  @inherits MyStore.Helpers.BaseViewPage&lt;TModel&gt;
  @addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
  </code></pre>
  
  <p>Whenever I try to use any property in my view - <code>ProductCategories.cshtml</code> the error invokes here </p>
  
  <blockquote>
    <p>Severity  Code    Description Project File    Line    Suppression State
    Error CS7036  There is no argument given that corresponds to the
    required formal parameter '_principal' of
    'BaseViewPage.BaseViewPage(IPrincipal)'  MyStore D:\Projects\TWCStore\TWCStore\Views\Store\ProductCategories.cshtml  1   Active</p>
  </blockquote>
  
  <p>I am assuming when I am injecting the dependency then it wants me to put the <code>IPrincipal</code> as Dependency here too - </p>
  
  <pre><code> @inherits MyStore.Helpers.BaseViewPage&lt;TModel&gt;
  </code></pre>
  
  <p>How do I inject this dependency in here ?</p>