c# - ASP.NET Redirect user to current custom domain after Azure Active Directory Authentication -


i trying redirect users domain on tried access website before being redirected azure active directory login page. using openidconnect, , following bit of code defines uri on user needs redirected post-login :

notifications = new openidconnectauthenticationnotifications                 {                     redirecttoidentityprovider = context =>                     {                         string appbaseurl = "https://" + context.request.host + context.request.pathbase + context.request.uri.pathandquery;                         context.protocolmessage.redirecturi = "https://" + context.request.host + context.request.pathbase + context.request.uri.pathandquery;                         context.protocolmessage.postlogoutredirecturi = appbaseurl;                         return task.fromresult(0);                     },                      //custom validation                     securitytokenvalidated = onvalidate,                     authenticationfailed = onfailure                 } 

the issue having have custom domains , context.request.host returns generic domain of website instead of need.

for instance, have website , 2 custom domains :

  • mywebsite.azurewebsites.net generic host
  • mywebsite.customdomain1.com
  • mywebsite.customdomain2.com

when connecting mywebsite.customdomain1.com, context.request.host equal mywebsite.azurewebsites.net. not knowing domain users come from, forced redirect them unique domain ... not ideal.

what options here ?

updating on issue, problem came fact use cdn provide access website customdomain1 , customdomain2. cdn badly configured , did not let through original hostname request received. changed configuration , works now.


Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -