Docker Community Forums

Share and learn in the Docker community.

Migration from ASP.NET 4.0 Web App using ASHX to Docker


(Robertloureiro) #1


I am new to Docker, and currently attempting to migrate my ASP NET 4.0 Web App to Docker as a ‘lift and shift’ (no coding changes).

All of the samples that I have seen, and even the ASP NET aspnetapp sample have a defined application starting point. My app. on the other hand, uses ASHX files to launch.

For example, after installating my application (via MSIEXEC), I launch the app in the browser using:

http ://localhost/{application name}/{page name}.ashx.

How can I tell docker to launch my contained image using {page name}.ashx?

Also note that this app runs using IIS.

Here is my current dockerfile:

FROM microsoft/aspnet:4.7
WORKDIR /inetpub/wwwroot
COPY . .
COPY ./bin ./bin
COPY ./html ./html
COPY ./InstallInfo ./InstallInfo
COPY ./log ./log
COPY ./scripts ./scripts

Also, do I need to include microsoft/iis, or is is part or microsoft/aspnet:4.7?

I am attempting this on Windows Server 2016.
Docker version 18.03-0-ce.

Thanks, RobL

(Robertloureiro) #2

I have now modified my dockerfile to be:


FROM microsoft/iis:10.0.14393.206
SHELL [“powershell”, “-command”]

RUN Install-WindowsFeature NET-Framework-45-ASPNET; `
Install-WindowsFeature Web-Asp-Net45


RUN Remove-Website -Name ‘Default Web Site’; md c:\sample;
md c:\sample\bin; md c:\sample\html;
md c:\sample\InstallInfo; md c:\sample\log;
md c:\sample\scripts; New-Website -Name 'sample'
-Port 8081 -PhysicalPath ‘c:\sample’ `
-ApplicationPool ‘.NET v4.5’

RUN Start-Service -Name ‘aspnet_state’

CMD sc config aspnet_state start=auto
CMD net start aspnet_state
RUN Set-ItemProperty Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters `
-Name AllowRemoteConnection -Value 1
CMD net stop aspnet_state
CMD net start aspnet_state

COPY . c:\sample
COPY .\bin c:\sample\bin
COPY .\html c:\sample\html
COPY .\InstallInfo c:\sample\InstallInfo
COPY .\log c:\sample\log
COPY .\scripts c:\sample\scripts

With this modified dockerfile I seem to get close to launching my web client.
With the IP address obtained from ‘docker inspect’, I enter the following into my browser:


After a few seconds, I end up with “Server Error in ‘/’ Application”:

Unable to make the session state request to the session state server. Please ensure that the ASP NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either ‘localhost’ or ‘’ as the server name.

As you can see in my dockerfile I am attempting to start the ‘aspnet_state’ service. I actually tried to start it 2 different ways - with CMD and again with Powershell.

I’m not sure if the service is actually started or not. ‘docker log’ does no reveal anything.

I have read that I shouldn’t use session state, but my existing ASP NET web client was designed/built that way, and I was hoping not to modify any code to get my client to run in docker.

Has anyone been successful with using session state in docker?

Is there a way to see if the service is started?

Have I missed something in my dockerfile?

Thanks, Rob