how to redirect users if a POST request is done by the user in azure portal deployment slot?, when a request POST is done by the user is not beign redirected to the slot

Jimmy 1 Reputation point
2022-07-08T05:36:53.917+00:00

Hi everyone

Could you please help me with this issue?

In Azure portal there is a service for the deployment slot

  • the main application is the web production slot production
  • the secondary is a C# core 5.0 application always redirecting to the index page (offline application)

in the the secondary application the Startup.cs file I set up the error handle 404 as follows

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)  
{  
    if (env.IsDevelopment())  
    {  
        app.UseDeveloperExceptionPage();  
    }  
    else  
    {  
        app.UseExceptionHandler("/Error");                
        app.UseHsts();  
    }  
  
    app.UseHttpsRedirection();  
    app.UseStaticFiles();  
  
    // Here is our middleware registration for error status code handling   
    app.UseStatusCodePagesWithReExecute("/Index");  
  
    app.UseRouting();  
  
    app.UseAuthorization();  
  
    app.UseEndpoints(endpoints =>  
    {  
        endpoints.MapRazorPages();  
    });  
}   

in the main application error handle I set up in the web config file as:

<customErrors mode="On" defaultRedirect="/Error" >  
    <error statusCode="404" redirect="/Error/NotFound"/>  <!--not found -->  
</customErrors>  

-Issue comes if the user is navigating on the main page after changing the traffic in the slot main to 0 percent and secondary slot to 100 percent:

if the user is on the main page performing a process Request POST (e.g. click submit button) user is not being redirected to the secondary slot (offline page)

  • however, there is no issue if a user is navigating from one page to another in the main application like request GET (url) user is being redirected to the secondary slot page

thanks in advance for your advice on how to get a solution for it

C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,651 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,408 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ryan Hill 27,111 Reputation points Microsoft Employee
    2022-07-09T04:24:28.267+00:00

    Hi @Jimmy ,

    App service will route production traffic automatically by pinning the session to the slot through x-ms-routing-name cookie. In your client session, look for x-ms-routing-name in the header. You may be able to check AppServiceHTTPLogs if you're using Azure Monitor. If you're changing the traffic in the portal from 0 -100, this probably what's happening to your session. One thing you could do check for that cookie when hostname is the slot URI and either append ?x-ms-routing-name=slot to the request URL or add it directly to the cookie.

    0 comments No comments