Blazor Server App cannot remove Identity Pages

I have a Blazor Server App. It authenticates via SSO, so I have no need for Identity/Account/Login or Identity/Account/Register. I have tried a number of things to remove them, but nothing seems to work. Things I have tried:

  1. I have deleted the files, but the app seems to still redirect to them.

  2. Reroute endpoints in Startup.cs Config method:

    app.UseEndpoints(endpoints =>
    { 
          //try to redirect to the home page   
          endpoints.MapGet("/Identity/Account/Register", context => Task.Factory.StartNew(() => context.Response.Redirect("/", true, true)));
          endpoints.MapPost("/Identity/Account/Register", context => Task.Factory.StartNew(() => context.Response.Redirect("/", true, true)));
         endpoints.MapControllers();
         endpoints.MapBlazorHub();
         endpoints.MapFallbackToPage("/_Host");                
    });
    

All this does is redirect from the Register page to the Login page

  1. Re-scaffold the Register/RegisterConfrimation/Login pages and updated them as this:

Register.cshtm

public class RegisterModel : PageModel
    {
        public IActionResult OnGet()
        {
          return Redirect("~/");
        }

        public IActionResult OnPost()
        {
            return Redirect("~/");
        }
    }

But this also just redirects to the Login page.

  1. Update links to point to another page. Yes, I can do this, but users can still type in the URL and go to the Login or Register pages

So, how do I remove these pages so users cannot access them?

Update It seems if I run my app in debug (Debug->Start Debugging) this works. But, if I run it al control+F5 it does not work. I'm not sure what the difference is?

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum