# Trying out asp.net core in .net 6 and having a redirect issue I cannot explain

**URL:** <https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221>\
**Category:** Get Help\
**Tags:** aspnet-core, auth0\
**Created:** [October 13, 2021, 5:05am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221 "2021-10-13T05:05:26Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeff9](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff9/32/12681_2.png) [@jeff9](https://community.auth0.com/u/jeff9)\
**Post date:** [October 13, 2021, 5:05am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221/1 "2021-10-13T05:05:26Z")

</div>

I am following the [ASP.NET](http://ASP.NET) Core: Login quickstart article, link is account specific so I cannot provide it here. I am also adapting it to C# 10/.net 6.

It is using razor pages and a two MapGets to setup logging in and out.

One the razor page, the login is: [Login](https://community.auth0.com/login) I am specifically avoiding asp-… helpers because instead of using an AccountController, I am using two smaller minimal api calls:

```auto
app.MapGet("/login", async context => {
    var returnUrl = context.Request.Query["returnUrl"] switch
    {
        StringValues { Count: 0 } => "/",
        StringValues { Count: int n } results => results[n - 1]
    };

    await context.ChallengeAsync(new AuthenticationProperties() { RedirectUri = returnUrl });
});

```

What I expected to happen is that this /login call would redirect over to auth0, but instead it is trying to go to: **[https://localhost:7147/Account/Login?ReturnUrl=%2F](https://localhost:7147/Account/Login?ReturnUrl=%2F)**

The link for login appears rightly as /login and that handler above is invoked. I am at my wits-end trying to figure out where this /Account/Login stuff is coming from because it isn’t specified ANYWHERE in the application. I realize the sample uses an AccountController. I am suspecting this behaviour is something built into [asp.net](http://asp.net) core that my google-fu is not good enough to find.

The project I have built is at: [https://github.com/idea-plex/IdeaPlexWeb/blob/main/Program.cs](https://github.com/idea-plex/IdeaPlexWeb/blob/main/Program.cs)

It is not necessarily the case that all of the auth0 settings are configured correctly in the webapp, note that credientials won’t be found in the repo, they are stored in the secrets.

Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![jeff9](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff9/32/12681_2.png) [@jeff9](https://community.auth0.com/u/jeff9)\
**Post date:** [October 13, 2021, 5:13am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221/2 "2021-10-13T05:13:46Z")

</div>

I have happened upon some code that indeed changes the paths for the cookie, such as:

```auto
.AddCookie(CookieAuthenticationDefaults.AuthenticationScheme, options =>
{
    options.LoginPath = "/login";
    options.LogoutPath = "/logout";
})

```

However, it will just create an infinite loop, but for some reason the same thing in the sample using the AccountController doesn’t create an infinite loop.

---

<div class="post-metadata">

**Author:** ![jeff9](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/jeff9/32/12681_2.png) [@jeff9](https://community.auth0.com/u/jeff9)\
**Post date:** [October 13, 2021, 5:52am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221/3 "2021-10-13T05:52:42Z")

</div>

So it turns out all I had to do was add “Auth0” to the ChallengeAsync. That detail might have been nice to have in the quickstart.

Right now I can login and logout, which is great!

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [October 13, 2021, 11:20am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221/4 "2021-10-13T11:20:29Z")

</div>

Perfect! Glad to hear that and thanks for sharing with the rest of community! I’m gonna pass it as feedback to our team responsible for quickstarts!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [October 28, 2021, 11:21am UTC](https://community.auth0.com/t/trying-out-asp-net-core-in-net-6-and-having-a-redirect-issue-i-cannot-explain/71221/5 "2021-10-28T11:21:13Z")

</div>

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.
