I am trying to dockerize an existing ASP.NET MVC application running on .NET 4.5.2. I am using mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019 as the base image (the base image includes IIS).
I am able to build and run the container with the correct port mapping. When I make a request to an action method, I get a 404 and the detailed error information specifies ManagedPipelineHandler as the module and System.Web.Mvc.MvcHandler as the handler (I have enabled detailed error logs and disabled custom errors). Note that making a request to an authorized action method causes a redirect to the login action method, which then gives 404. This means that the application is running, and handlers in Global.asax are being hit.
Dockerfile:
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
RUN ["powershell.exe", "Install-WindowsFeature NET-Framework-45-ASPNET"]
RUN ["powershell.exe", "Install-WindowsFeature Web-Asp-Net45"]
#Installing IIS modules
RUN powershell -Command "Install-WindowsFeature web-scripting-tools; \
Install-WindowsFeature Web-Http-Tracing; \
Install-WindowsFeature Web-Basic-Auth; \
Install-WindowsFeature Web-Client-Auth; \
Install-WindowsFeature Web-CertProvider; \
Install-WindowsFeature Web-Windows-Auth; \
Install-WindowsFeature Web-Dyn-Compression; \
Install-WindowsFeature Web-Http-Redirect; \
Install-WindowsFeature Web-Custom-Logging; \
Install-WindowsFeature Web-ISAPI-Ext; \
Install-WindowsFeature Web-Net-Ext45; \
Install-WindowsFeature Web-AppInit; \
Install-WindowsFeature Web-Includes; \
Install-WindowsFeature Web-DAV-Publishing;"
RUN powershell -NoProfile -Command "Invoke-WebRequest -Uri 'https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi' -OutFile 'C:\rewrite.msi'; \
Start-Process msiexec.exe -ArgumentList '/i C:\rewrite.msi /quiet /norestart' -Wait; \
Remove-Item C:\rewrite.msi -Force; \
Invoke-WebRequest -Uri 'https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi' -OutFile 'C:\requestRouter.msi'; \
Start-Process msiexec.exe -ArgumentList '/i C:\requestRouter.msi /quiet /norestart' -Wait; \
Remove-Item C:\requestRouter.msi -Force"
WORKDIR /inetpub/wwwroot
COPY build-output/ .
EXPOSE 80
What I've tried:
I have tried hosting the same build output on local via IIS, and this works fine. The requests hit the appropriate controllers.
I have tried building the docker image with IIS image as base and installing .net framework in the dockerfile. I get the same error with that setup as well.
I have also explored some potential issues like file permissions referenced here. This doesn't seem to be the issue in my case.
On a side note, I'm also facing issues in setting up failed request tracing. I've tried installing the module in the container and enabling it using appcmd (similar to this setup), but I don't see any log files being generated in the FailedReqLogFiles directory.
Any pointers on potential causes for the 404 would be much appreciated.