title: 500 Internal Server Error Docker Hosted ASP.Net MVC web app (RESOLVED)
body: <p>We have a ASP.Net MVC app and which works fine when we run even locally in debug mode from Visual Studio.
  We have 4 Class library projects and one web api project. Following is my docker file:</p>
  <pre><code>FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
  WORKDIR /app
  
  # copy csproj and restore as distinct layers
  COPY *.sln .
  COPY xxxxx/*.csproj ./xxxxx/
  COPY yyyyyy/*.csproj ./yyyyy/
  # copy everything else and build app
  COPY xxxxx/ ./xxxxx/
  COPY yyyyy/ ./yyyyy/
  RUN nuget restore
  
  WORKDIR /app/GetThree
  RUN msbuild /p:Configuration=Release
  
  FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8 AS runtime
  WORKDIR /inetpub/wwwroot
  COPY --from=build /app/xxxxx/. ./
  </code></pre>
  <p>Once I build the docker file, everything compiles properly and build is successful also (all Nuget packages are restored) and I am able to create the container as well. But unfortunately whenever I try to browse to my web-app (I got the IP address of the container as this is windows base) but unfortunately I get HTTP 500 internal server error immediately. I have made sure that the HTTPERROR section is set for detailed error message.</p>
  <p>As soon as I navigate to the ip address I get this 500 error and unfortunately not much is availble in the logs (Application or System) which will help me as to what the issue could be.  Any help?</p>
  <p>Following is the command I use to build and run the container:</p>
  <pre><code>docker build -f .\GetThree\Dockerfile -t threecms/cmsdocker:1.0 
  docker run --name threecms --rm -it -p 8100:80 threecms/cmsdocker:1.0
  </code></pre>
  <p>To browse the site I get the IP Address (using docker exec threecms ipconfig) and I browse it using: http://ipadress:8100</p>
  <p>UPDATE 1:-</p>
  <p>I created one more image from above image using following dockerfile ( urlrewrite is the URLREWRITE module install script)</p>
  <pre><code>FROM threecms/cmsdocker:1.0
  WORKDIR C:/
  Copy urlrewrite.ps1/ .
  RUN &quot;Powershell ./urlrewrite.ps1&quot;
  
  RUN Install-WindowsFeature Web-Mgmt-Service; \
  
  New-ItemProperty -Path HKLM:\software\microsoft\WebManagement\Server -Name EnableRemoteManagement -Value 1 -Force; \
  
  Set-Service -Name wmsvc -StartupType automatic;
  </code></pre>
  <p>URL REWRITE PS1 script:</p>
  <pre><code>New-Item c:/msi -ItemType Directory
  Invoke-WebRequest 'http://download.microsoft.com/download/C/F/F/CFF3A0B8-99D4-41A2-AE1A-496C08BEB904/WebPlatformInstaller_amd64_en-US.msi' -OutFile c:/msi/WebPlatformInstaller_amd64_en-US.msi
  Start-Process 'c:/msi/WebPlatformInstaller_amd64_en-US.msi' '/qn' -PassThru | Wait-Process
  cd 'C:/Program Files/Microsoft/Web Platform Installer'; .\WebpiCmd.exe /Install /Products:'UrlRewrite2,ARRv3_0' /AcceptEULA /Log:c:/msi/WebpiCmd.log
  </code></pre>
  <p>Then I ran the container using following command:-</p>
  <pre><code>docker run --name threecms2 -d cmswindfeature/cmswinfeature:3.0
  </code></pre>
  <p>And now whenever I got to my application from browser it gives me the actual error msg which is:</p>
  <pre><code>Access to the path 'C:\inetpub\wwwroot\App_Data\TEMP\PluginCache\umbraco-plugins.373F7AAE388A.hash' is denied.
  </code></pre>
  <p>UPDATE:-2  RESOLVED</p>
  <p>So to Resolve above error I ran the following Powershell script (To add required Permissions) and Boom I was able to access my site and its working now:-</p>
  <pre><code>$accessRule = New-Object System.Security.AccessControl.FileSystemAccessRule(&quot;IIS_IUSRS&quot;, &quot;FullControl&quot;, &quot;ContainerInherit,ObjectInherit&quot;, &quot;None&quot;, &quot;Allow&quot;)
  $acl = Get-ACL &quot;C:\inetpub\wwwroot&quot;
  $acl.AddAccessRule($accessRule)
  Set-ACL -Path &quot;C:\inetpub\wwwroot&quot; -ACLObject $acl
  </code></pre>