# ASP.NET Core incorrect redirect url

**URL:** <https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678>\
**Category:** Get Help\
**Tags:** aspnet-core, auth0\
**Created:** [June 1, 2021, 12:41pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678 "2021-06-01T12:41:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 1, 2021, 12:41pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/1 "2021-06-01T12:41:46Z")

</div>

Hello.

I uses auth0 to connect to my application.  
It works well localy but when i try to use it from the web I have a problem.

I uses the [ASP.Net](http://ASP.Net) Core sample provided in the documentation ([Auth0 ASP.NET Core MVC SDK Quickstarts: Login](https://auth0.com/docs/quickstart/webapp/aspnet-core/)), and I have configured the login, logout, and the callBack URL properly in auth0.  
My problem is that when I access to my service by is public adress and I hit the Login button, the url constructed by the service to call [auth0.com](http://auth0.com) indicates the local address in the “redirect\_uri” section and not the public one.  
Of course, this didn’t work because the local address isn’t globaly accessible…

My question is : where and how can I specified the right URL to use in the service ?

Any help greatly appreciated, thanks !

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 2, 2021, 9:28pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/3 "2021-06-02T21:28:51Z")

</div>

Hi @simonids,

Can you give us an example of the behavior? Screenshots may be helpful.

---

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 3, 2021, 6:52am UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/4 "2021-06-03T06:52:31Z")

</div>

Hi,

First of all, thanks for your answer.

Here is a screenshot of my service based on the example from auth0 documentation. It runs on a IIS server, and is accessible from a public domain name (wich I overwrite here for confidentiality raisons).

 ![Screenshot](https://global.discourse-cdn.com/auth0/original/3X/a/d/addd5a5a9afda6af4e7ed899a0c63064974d41be.jpeg)

The problem is, when you use the Login/Connexion button, the URL that is automatically built is like this : [https://XYZ.auth0.com/authorize?client\_id=MY\_CLIENT\_ID&redirect\_uri=https%3A%2F%2F\*\*MY\_LOCAL\_IP\_ADDRESS\_AND\_PORT\*\*%2Fcallback&](https://XYZ.auth0.com/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2F **MY_LOCAL_IP_ADDRESS_AND_PORT** %2Fcallback&)…  
And I need it to be like that to be ok : [https://XYZ.auth0.com/authorize?client\_id=MY\_CLIENT\_ID&redirect\_uri=https%3A%2F%2F\*\*MY\_PUBLIC\_DOMAIN\_NAME.com\*\*%2Fcallback&](https://XYZ.auth0.com/authorize?client_id=MY_CLIENT_ID&redirect_uri=https%3A%2F%2F **MY_PUBLIC_DOMAIN_NAME.com** %2Fcallback&)…

Thanks.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 3, 2021, 2:51pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/5 "2021-06-03T14:51:51Z")

</div>

How are you setting your redirect URI? This should be a parameter you send with your request to the /authorize endpoint, and can be configured to whatever you prefer.

Showing us a code sample of your Auth0 implementation could help.

---

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 4, 2021, 6:52am UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/6 "2021-06-04T06:52:08Z")

</div>

Hi,

The problem is I don’t set it : it’s set automatically by the Web Service.  
My application is 98% like the sample app proposed on the help ([Auth0 ASP.NET Core MVC SDK Quickstarts: Login](https://auth0.com/docs/quickstart/webapp/aspnet-core)) but to be sure I do nothing wrong I just send you by private message my code.  
As you will see, I never set the redirect URL, and therefore I have no idea how to do it to resolve my problem.

Thank you for your help.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 7, 2021, 10:55pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/7 "2021-06-07T22:55:41Z")

</div>

Hmmm, that is a good question. I don’t have much .NET core experience. Let me reach out to the team and get an answer for you.

---

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 8, 2021, 7:06am UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/8 "2021-06-08T07:06:09Z")

</div>

Thanks for your answer, so I’m waiting for the rest of the team 😉

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 8, 2021, 3:28pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/9 "2021-06-08T15:28:15Z")

</div>

Here was the response from one of our engineers:

> This redirect URL is generated by the Microsoft.AspNetCore.Authentication.OpenIdConnect library used in .NET apps. Usually you’d want to have the redirect URL in the same domain as the app.  
> However, if the problem is that the app is not aware of the domain because the request come through a load balancer etc, they may need to use the x-forwarded-for headers [nginx - AspNetCore Azure AD Connect Callback URL is http, not https - Stack Overflow](https://stackoverflow.com/questions/49407573/aspnetcore-azure-ad-connect-callback-url-is-http-not-https)

> **[Configure ASP.NET Core to work with proxy servers and load balancers](https://learn.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-5.0)**
>
> Learn about configuration for apps hosted behind proxy servers and load balancers, which often obscure important request information.

---

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 10, 2021, 9:54am UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/10 "2021-06-10T09:54:59Z")

</div>

Thank you and your team for your answer.  
I’m currently checking the links you provide, and will come back to tell if I managed to resolve my problem.

---

<div class="post-metadata">

**Author:** ![simonids](https://upload.wikimedia.org/wikipedia/commons/thumb/7/7c/User_font_awesome.svg/768px-User_font_awesome.svg.png) [@simonids](https://community.auth0.com/u/simonids)\
**Post date:** [June 10, 2021, 1:40pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/11 "2021-06-10T13:40:18Z")

</div>

Problem solved !  
In fact, it wasn’t a problem with the web service but a configuration on IIS that wasn’t correct… I found the solution thanks to the links you sent me, thanks a lot.

---

<div class="post-metadata">

**Author:** ![dan.woda](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/dan.woda/32/18340_2.png) [@dan.woda](https://community.auth0.com/u/dan.woda)\
**Post date:** [June 10, 2021, 5:36pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/12 "2021-06-10T17:36:28Z")

</div>

Great, thanks for the update! I am going to mark this one solved with the links for future users.

---

<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:** [June 25, 2021, 5:37pm UTC](https://community.auth0.com/t/asp-net-core-incorrect-redirect-url/63678/13 "2021-06-25T17:37:18Z")

</div>

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