title: Authorization requires a cascading parameter of type Task<AuthenticationState>. Consider using CascadingAuthenticationState to supply this
body: <p>I have a Blazor server-side project that was set up with Individual Accounts. I scaffolded the AspNet.Core.Identity pages and wish to use a Blazor component inside one of the razor pages
  by using the <code>&lt;component&gt;</code>tag helper.</p>
  <p>My Razor page:</p>
  <pre><code>@page
  @using SenseNet.Pages
  @model WalletModel
  @{
      ViewData[&quot;Title&quot;] = &quot;Wallet Data&quot;;
      ViewData[&quot;ActivePage&quot;] = &quot;WalletData&quot;;
  }
  @{
      Layout = &quot;_Layout.cshtml&quot;;
  }
  &lt;h3&gt;@ViewData[&quot;Title&quot;]&lt;/h3&gt;
  &lt;component type=&quot;typeof(Counter)&quot; render-mode=&quot;ServerPrerendered&quot; /&gt;
  </code></pre>
  <p>My Counter Blazor component:</p>
  <pre><code>@page &quot;/counter&quot;
  
  &lt;PageTitle&gt;Counter&lt;/PageTitle&gt;
  &lt;h1&gt;Counter&lt;/h1&gt;
  
  &lt;AuthorizeView Policy=&quot;TwoFactorEnabled&quot;&gt;
      &lt;h1&gt;Hello, @context.User.Identity.Name!&lt;/h1&gt;
      &lt;p&gt;You can only see this content if you're authenticated.&lt;/p&gt;
  &lt;/AuthorizeView&gt;
  
  &lt;p role=&quot;status&quot;&gt;Current count: @currentCount&lt;/p&gt;
  
  &lt;button class=&quot;btn btn-primary&quot; @onclick=&quot;IncrementCount&quot;&gt;Click me&lt;/button&gt;
  
  @code {
      [CascadingParameter]
      private Task&lt;AuthenticationState&gt; authenticationStateTask { get; set; }
  
      private int currentCount = 0;
  
      private void IncrementCount()
      {
          currentCount++;
      }
  }
  </code></pre>
  <p>My CascadingAuthenticationState setup in App.razor:</p>
  <pre><code>&lt;CascadingAuthenticationState&gt;
      &lt;Router AppAssembly=&quot;@typeof(App).Assembly&quot;&gt;
          &lt;Found Context=&quot;routeData&quot;&gt;
              &lt;AuthorizeRouteView RouteData=&quot;@routeData&quot; DefaultLayout=&quot;@typeof(MainLayout)&quot; /&gt;
              &lt;FocusOnNavigate RouteData=&quot;@routeData&quot; Selector=&quot;h1&quot; /&gt;
          &lt;/Found&gt;
          &lt;NotFound&gt;
              &lt;PageTitle&gt;Not found&lt;/PageTitle&gt;
              &lt;LayoutView Layout=&quot;@typeof(MainLayout)&quot;&gt;
                  &lt;p role=&quot;alert&quot;&gt;Sorry, there's nothing at this address.&lt;/p&gt;
              &lt;/LayoutView&gt;
          &lt;/NotFound&gt;
      &lt;/Router&gt;
  &lt;/CascadingAuthenticationState&gt;
  </code></pre>
  <p>When I load the page, I get <code>InvalidOperationException: Authorization requires a cascading parameter of type Task&lt;AuthenticationState&gt;. Consider using CascadingAuthenticationState to supply this.</code></p>
  <p>I have tried implementing the troubleshooting solutions as described here: <a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-6.0#expose-the-authentication-state-as-a-cascading-parameter" rel="nofollow noreferrer">https://docs.microsoft.com/en-us/aspnet/core/blazor/security/?view=aspnetcore-6.0#expose-the-authentication-state-as-a-cascading-parameter</a> but I'm at a loss since even though I followed the cascading parameters suggestion as seen from the code above, it does not change the error message. When I remove the  tags from the Blazor component, it works.</p>
  <p>Am I doing things in the wrong order here? Is it even possible to use <code>&lt;AuthorizeView&gt;</code> tags if the component is going to be rendered on a Razor page?</p>