title: AuthorizeRouteView Authorizing and NotAuthorized parameters settings
body: <p>I wanted to use the <code>NotAuthorized</code> attribute in the <code>&lt;AuthorizeRouteView&gt;</code> tag to redirect to the login page every time a non logged-in user try to access a page.</p>
  
  <p>Howewer, it requires a <code>RenderFragment&lt;AuthentificationState&gt;</code> typed parameter. What shoud I put to set this parameter to render the login page ?</p>
  
  <p><strong>Edit :</strong> Code is pretty simple. I used the Blazor server side project template with identity stored in application, just added the <code>RedirectToLogin.razor</code> like this :</p>
  
  <pre><code>@inject NavigationManager NavigationManager
  @code { 
      protected override void OnAfterRender()
      {
          NavigationManager.NavigateTo("counter"); //for an unknown reason, the "Identity/Account/Login" redirect doesn't work.
      }
  }
  </code></pre>
  
  <p>And modified the <code>App.razor</code> :</p>
  
  <pre><code>&lt;CascadingAuthenticationState&gt;
      &lt;Router AppAssembly="@typeof(Program).Assembly"&gt;
          &lt;Found Context="routeData"&gt;
              &lt;AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"&gt;
                  &lt;NotAuthorized&gt;
                      @if(true) { } //Used for breakpoint.
                      &lt;RedirectToLogin /&gt;
                  &lt;/NotAuthorized&gt;
                  &lt;Authorizing&gt;
                      @if(true) { } //Used for breakpoint.
                  &lt;/Authorizing&gt;
              &lt;/AuthorizeRouteView&gt;
          &lt;/Found&gt;
          &lt;NotFound&gt;
              &lt;LayoutView Layout="@typeof(MainLayout)"&gt;
                  &lt;p&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>I didn't touch the <code>Startup.cs</code> so it look like this :</p>
  
  <pre><code>public class Startup
      {
          public Startup(IConfiguration configuration)
          {
              Configuration = configuration;
          }
  
          public IConfiguration Configuration { get; }
  
          // This method gets called by the runtime. Use this method to add services to the container.
          // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
          public void ConfigureServices(IServiceCollection services)
          {
              services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
                  options.UseSqlServer(
                      Configuration.GetConnectionString("DefaultConnection")));
              services.AddDefaultIdentity&lt;IdentityUser&gt;()
                  .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;();
              services.AddRazorPages();
              services.AddServerSideBlazor();
              services.AddScoped&lt;AuthenticationStateProvider, RevalidatingIdentityAuthenticationStateProvider&lt;IdentityUser&gt;&gt;();
              services.AddSingleton&lt;WeatherForecastService&gt;();
          }
  
          // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
          public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
          {
              if (env.IsDevelopment())
              {
                  app.UseDeveloperExceptionPage();
                  app.UseDatabaseErrorPage();
              }
              else
              {
                  app.UseExceptionHandler("/Error");
                  // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                  app.UseHsts();
              }
  
              app.UseHttpsRedirection();
              app.UseStaticFiles();
  
              app.UseRouting();
  
              app.UseAuthentication();
              app.UseAuthorization();
  
              app.UseEndpoints(endpoints =&gt;
              {
                  endpoints.MapControllers();
                  endpoints.MapBlazorHub();
                  endpoints.MapFallbackToPage("/_Host");
              });
          }
      }
  </code></pre>