Skip to content

latest mcr.microsoft.com/dotnet/aspnet:9.0 on ubuntu-latest causing 307 redirects from app.UseHttpsRedirection(); #62333

Closed
@adambient

Description

@adambient

Describe the bug

In my Azure Web App for Containers application which I publish via Azure DevOps using these images in my Dockerfile

FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS base
ENV TZ=Europe/London
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
...

Causes my website to continually redirect giving ERR_TOO_MANY_REDIRECTS in e.g. chrome. As part of my investigation I found that removing this line of code from my Startup.cs

app.UseHttpsRedirection();

prevented the continual redirects but it broke the authentication flow so is not a solution.

Going back to previous working images so that my Dockerfile is as follows fixes the issue

FROM mcr.microsoft.com/dotnet/aspnet@sha256:d5507d8292fb2469ec0b9913f3cd4bb8d5a014bd6dc00c33fd4c4e7310229f07 AS base
ENV TZ=Europe/London
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk@sha256:c5b188baf837b0180a14f988815b9cc7a55b836dd6cbe1b6e6523cf3098faaa8 AS build

So I believe the issue is with the current version of mcr.microsoft.com/dotnet/aspnet:9.0 and possibly mcr.microsoft.com/dotnet/sdk:9.0.

I am publishing to my web app for containers using ubuntu-latest

Which .NET image(s) are you using?

mcr.microsoft.com/dotnet/aspnet:9.0
mcr.microsoft.com/dotnet/sdk:9.0

Steps to reproduce

Publish an ASP.NET Core Web Application to Azure Web App for Containers using ubuntu-latest with the docker file referencing mcr.microsoft.com/dotnet/aspnet:9.0 and in the Startup.cs have app.UseHttpsRedirection();

Other information

A workaround is to use older images so that the Dockerfile is something like

FROM mcr.microsoft.com/dotnet/aspnet@sha256:d5507d8292fb2469ec0b9913f3cd4bb8d5a014bd6dc00c33fd4c4e7310229f07 AS base
ENV TZ=Europe/London
WORKDIR /app
EXPOSE 8080
EXPOSE 8081

FROM mcr.microsoft.com/dotnet/sdk@sha256:c5b188baf837b0180a14f988815b9cc7a55b836dd6cbe1b6e6523cf3098faaa8 AS build

Output of docker version

using Task : Docker in Azure DevOps Version 2.256.1 so not sure which version of docker

Output of docker info

using Task : Docker in Azure DevOps Version 2.256.1 so not sure which version of docker

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: AnsweredResolved because the question asked by the original author has been answered.Status: Resolvedarea-middlewareIncludes: URL rewrite, redirect, response cache/compression, session, and other general middlewares

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions