can't redirect back to my custom domain URL

yehonatan fridman 0 Reputation points
2023-11-16T08:44:53.2033333+00:00

Hi,
I have a problem with the DOMAIN URL in my Razor Page web app.

Here is the original URL which looks like this:

https://mySiteName-stage-bo.azurewebsites.net

And there is the custom domain:

https://officestage.mySiteName.com

I am using the services of an external provider in order to perform 2FA.

Basically what happens is, that after a user enters the email and password, he is transferred to their external page where he has to perform another identification and then he successfully connects and enters the APP.

I need to give an address to which the user should return at the end of the process. The settings look like this:

                         var request = new TrackRequest(

                             UserId: employee.Id.ToString(),

                             Email: employee.Email,

                             Action: "signin",

                             RedirectUrl: $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/Login?handler=AuthsignalCallback"

                          );

If the visitor enters via the original URL (mySiteName-stage-bo.azurewebsites.net) then there is no error and everything is fine and works smoothly.

The problem is when the user enters from the custom domain.

For some reason this section:

                             RedirectUrl: $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host}/Login?handler=AuthsignalCallback"

Returns me the original URL and not the CUSTOM one.

I consulted the support of the third-party vendor and he directed me to this Microsoft article:

https://video2.skills-academy.com/en-us/azure/architecture/best-practices/host-name-preservation

Emphasis on the part of Incorrect redirect URLs

We do use application Gateawy in our Azure.

Is it possible that im missing some settings ?

Basically, I need to make sure that when a visitor connects through the custom domain, he will be returned to the custom domain and not to the original host url.

I've tried to change the way I'm getting the URL in my code and also tried to change some settings in my Startup.cs but all results were the same ..

Azure DNS
Azure DNS
An Azure service that enables hosting Domain Name System (DNS) domains in Azure.
629 questions
Azure Application Gateway
Azure Application Gateway
An Azure service that provides a platform-managed, scalable, and highly available application delivery controller as a service.
1,003 questions
{count} votes