![](/img/trans.png)
[英]Why is my docker container's timestamp wrong when running an ASP.NET Framework 4.7 application?
[英]Running ASP.NET 4.6 application inside a docker container - Site always 404s
我一直試圖使ASP.NET 4.6應用程序在Windows Docker容器中運行,而讓IIS與默認網站一起運行非常簡單,但是要使我的實際應用程序運行卻很困難。 每當我嘗試加載我的應用程序時,它都會返回未找到的404文件。
一些背景:我試圖運行該應用程序有根據“默認Web站點”與應用程序和IIS,其中SharedContent 也是主要的應用程序下一個子應用程序下安裝一個SharedContent應用程序都安裝。
這導致3次調用在IIS下安裝應用程序:
RUN ["powershell", "New-WebApplication -Name MvcCompaniesV2 -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/MvcCompaniesV2 -ApplicationPool DefaultAppPool"]
RUN ["powershell", "New-WebApplication -Name SharedContent -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/SharedContent -ApplicationPool DefaultAppPool"]
RUN ["powershell", "New-WebApplication -Name MvcCompaniesV2/SharedContent -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/SharedContent -ApplicationPool DefaultAppPool"]
擺弄整整一天后,我感到困惑。 我設法安裝了IIS WebManagement,並且可以使用IIS管理器連接到我的容器,並且可以看到我的網站已正確配置,但有一個例外:IIS設置中看不到來自web.config的連接字符串和重寫規則,例如它無法訪問配置文件。 IIS在IIS APPPOOL \\ DefaultAppPool用戶下運行,並且wwwroot文件夾已將IIS_IUSRS添加到其ACL(默認情況下)。
這是我的docker文件:
FROM microsoft/aspnet:4.7.2-windowsservercore-1803
EXPOSE 80
EXPOSE 8172
EXPOSE 4020 4021 4022 4023
# WebManagement stuff
RUN ["powershell.exe", "Install-WindowsFeature NET-Framework-45-ASPNET"]
RUN ["powershell.exe", "Install-WindowsFeature Web-Asp-Net45"]
RUN ["powershell.exe", "Install-WindowsFeature web-mgmt-service"]
RUN ["powershell.exe", "Set-ItemProperty -Path 'HKLM:/SOFTWARE/Microsoft/WebManagement/Server' -Name 'EnableRemoteManagement' -Value 1"]
RUN ["powershell.exe", "set-service -Name WMSVC -StartupType Automatic"]
RUN ["powershell", "start-service WMSVC"]
RUN ["powershell", "net user patrick l0lp@ssw0rd /add"]
RUN ["powershell", "net localgroup administrators patrick /add"]
# Rewrite module
ADD https://download.microsoft.com/download/C/9/E/C9E8180D-4E51-40A6-A9BF-776990D8BCA9/rewrite_amd64.msi rewrite_amd64.msi
RUN ["powershell" , "Start-Process msiexec.exe -ArgumentList '/i', 'rewrite_amd64.msi', '/quiet', '/norestart' -NoNewWindow -Wait"]
# Remote debugger
RUN Invoke-WebRequest -OutFile c:\rtools_setup_x64.exe -Uri https://aka.ms/vs/15/release/RemoteTools.amd64ret.enu.exe;
RUN & 'c:\rtools_setup_x64.exe' /install /quiet
ADD bin C:/inetpub/wwwroot/
RUN ["powershell", "New-WebApplication -Name MvcCompaniesV2 -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/MvcCompaniesV2 -ApplicationPool DefaultAppPool"]
RUN ["powershell", "New-WebApplication -Name SharedContent -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/SharedContent -ApplicationPool DefaultAppPool"]
RUN ["powershell", "New-WebApplication -Name MvcCompaniesV2/SharedContent -Site 'Default Web Site' -PhysicalPath C:/inetpub/wwwroot/SharedContent -ApplicationPool DefaultAppPool"]
# ErrorPages mode to off
RUN ["powershell", "Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT' -filter 'system.web/customErrors' -name 'mode' -value 'Off'"]
RUN ["powershell", "Set-WebConfigurationProperty -filter 'system.webServer/httpErrors' -name 'errorMode' -value 'Detailed'"]
RUN ["Powershell", "Set-WebConfigurationProperty -pspath 'IIS:\Sites\Default Web Site\MvcCompaniesV2' -filter 'system.webServer/httpErrors' -name 'errorMode' -value 'Detailed'"]
ENTRYPOINT ["powershell", ""]
關於如何解決此問題的任何想法? 可以看出,我將IIS和.NET的errorPages模式都更改為詳細,但是每當我打開MvcCompaniesV2時,我仍然會得到非常有限的錯誤頁面( https://imgur.com/a/jvj9r7f )。 我有點主意,我可以嘗試解決此問題。
我嘗試了一個示例asp.net頁面(可直接在“默認網站”下運行,並且開箱即可正常工作)。
編輯:當我將遠程調試器附加到我的項目時,它會在框架代碼內以ArgumentException中斷:
System.ArgumentException
HResult=0x80070057
Message=The parameter 'C:/inetpub/wwwroot/MvcCompaniesV2\' is invalid.
Parameter name: C:/inetpub/wwwroot/MvcCompaniesV2\
我通過修復New-WebApplication調用中格式錯誤的“ PhysicalPath”來解決此問題。 調試器的ArgumentException放棄了它,IIS不允許/在路徑中。 將它們更新為C:\\\\inetpub\\\\wwwroot\\\\MvcCompaniesV2
,問題消失了。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.