Razor Page .net6 returns 'client has disconnected' when attempting redirection

19 views Asked by At

Using claims authentication and trying to ensure that some pages require that user is logged in. Seems no matter what I try the VS debugger always stops with:

Client has disconnected.
COMException: An operation was attempted on a nonexistent network connection. (0x800704CD)

I've tried several different methods to redirect: -- On the page: @if (!User.Identity.IsAuthenticated) HttpContext.Response.Redirect("/Index")

-- In code behind:

`public IActionResult OnGet()
 {
     if (User.Identity.IsAuthenticated)
     {
         return Page();
     }
         return RedirectToPage("/Index");
         (Also
           - return new RedirectToPageResult("/Index");
           - return Redirect("/Index")
         )  

 }`

If the user is authenticated, it works just fine. But if not, all attempts above give me the same error. -- if I click Continue in VS, it goes on to the Index page.

What am I doing wrong?

0

There are 0 answers