title: How to force start Asp.Net Core 3.0 application to use Identity Login Page
body: <p>I use Asp.Net Core 3.0.1 and I need to force redirect to Identity Login Page, but, the problem after I changed the startup configuration it still redirect me to /Home/Index page, and here is my startup class code: </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.
  public void ConfigureServices(IServiceCollection services)
  {
      //Conection Provider for Identity
      services.AddDbContext&lt;ApplicationDbContext&gt;(options =&gt;
          options.UseSqlServer(Configuration.GetConnectionString("yourConnection")));
  
      services.AddIdentity&lt;IdentityUser, IdentityRole&gt;(options =&gt; options.SignIn.RequireConfirmedAccount = true)
          .AddEntityFrameworkStores&lt;ApplicationDbContext&gt;()
          .AddDefaultTokenProviders();
  
  
      services.AddMemoryCache();
  
  
      services.Configure&lt;IdentityOptions&gt;(options =&gt;
      {
          //Password Settings
          options.Password.RequireDigit = true;
          options.Password.RequireLowercase = true;
          options.Password.RequireNonAlphanumeric = true;
          options.Password.RequireUppercase = true;
          options.Password.RequiredLength = 8;
          options.Password.RequiredUniqueChars = 1;
  
          //Lockout Settings
          options.Lockout.DefaultLockoutTimeSpan = TimeSpan.FromMinutes(5);
          options.Lockout.MaxFailedAccessAttempts = 3;
          options.Lockout.AllowedForNewUsers = true;
  
          //User settings
          options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+#";
          options.User.RequireUniqueEmail = true;
  
      });
  
      //Configure application cookie
      services.ConfigureApplicationCookie(options =&gt;
      {
          options.Cookie.HttpOnly = true;
          options.ExpireTimeSpan = TimeSpan.FromMinutes(1);
          options.LoginPath = "/Login";
          options.LogoutPath = "/Logout";
          options.AccessDeniedPath = "/AccessDenied";
          options.SlidingExpiration = true;
      });
  
  
      services.AddMvc(options =&gt;
      {
          options.EnableEndpointRouting = false;
      })
      .SetCompatibilityVersion(Microsoft.AspNetCore.Mvc.CompatibilityVersion.Version_3_0)
      .AddSessionStateTempDataProvider();
  
  
      services.AddDistributedMemoryCache();
      services.AddSession(options =&gt; {
          options.IdleTimeout = TimeSpan.FromMinutes(1);
      });
  
  
      services.AddTransient&lt;IEmailSender, EmailSender&gt;(i =&gt;
          new EmailSender(
              Configuration["EmailSender:Host"],
              Configuration.GetValue&lt;int&gt;("EmailSender:Port"),
              Configuration.GetValue&lt;bool&gt;("EmailSender:EnableSSL"),
              Configuration["EmailSender:UserName"],
              Configuration["EmailSender:Password"]
          ));
  
      services.AddControllersWithViews();
      services.AddRazorPages(options =&gt;
      {
          options.Conventions.ConfigureFilter(new IgnoreAntiforgeryTokenAttribute());
      });
  
  }
  
  
  public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
  {
      if (env.IsDevelopment())
      {
          app.UseDeveloperExceptionPage();
          app.UseDatabaseErrorPage();
      }
      else
      {
          app.UseExceptionHandler("/Home/Error");
          app.UseHsts();
      }
      app.UseHttpsRedirection();
      app.UseStaticFiles();
  
  
      app.UseRouting();
  
      app.UseAuthentication();
      app.UseAuthorization();
  
      app.UseSession();
      app.UseMvc(routes =&gt;
      {
          //routes.MapRoute(
          //    name: "Identity",
          //    template: "Identity/{controller=Account}/{action=Login}/{id?}");
  
          routes.MapAreaRoute(
              name: "Identity",
              areaName: "Identity",
              template: "Identity/{controller=Account}/{action=Login}/{id?}");
  
  
      });
  
      app.UseCookiePolicy();
  
      CreateRoles(serviceProvider).Wait();
      RotativaConfiguration.Setup((Microsoft.AspNetCore.Hosting.IHostingEnvironment) env);
  
  }
  </code></pre>
  
  <blockquote>
    <p><strong>How can I force my application to startup with /Account/Login in Identity area?</strong></p>
  </blockquote>
  
  <p>Here is some link I searched in the same problem:</p>
  
  <ol>
  <li><p><a href="https://stackoverflow.com/questions/40217623/redirect-to-login-when-unauthorized-in-asp-net-core">Redirect to login when unauthorized in ASP.NET Core</a></p></li>
  <li><p><a href="https://wakeupandcode.com/authentication-authorization-in-asp-net-core-razor-pages/" rel="nofollow noreferrer">https://wakeupandcode.com/authentication-authorization-in-asp-net-core-razor-pages/</a></p></li>
  <li><p><a href="https://dotnetcoretutorials.com/2017/09/16/cookie-authentication-asp-net-core-2-0/" rel="nofollow noreferrer">https://dotnetcoretutorials.com/2017/09/16/cookie-authentication-asp-net-core-2-0/</a></p></li>
  </ol>