powershell を使用して、.NET 4 アプリケーションを仮想ディレクトリにデプロイしようとしています。次のコードを使用します。
Import-Module webadministration
New-Item IIS:\AppPools\MainAppPool
Set-ItemProperty IIS:\AppPools\MainAppPool managedRuntimeVersion v4.0
New-Item IIS:\AppPools\Site1AppPool
Set-ItemProperty IIS:\AppPools\Site1AppPool managedRuntimeVersion v4.0
New-Item IIS:\Sites\DemoSite -physicalPath C:\DemoSite -bindings @{protocol="http";bindingInformation=":82:"}
Set-ItemProperty IIS:\Sites\DemoSite -name applicationPool -value DemoAppPool
New-Item IIS:\Sites\DemoSite\Site1 -physicalPath C:\Deployment\application -type VirtualDirectory
ConvertTo-WebApplication IIS:\Sites\DemoSite\Site1
Set-ItemProperty IIS:\sites\DemoSite\Site1 -name applicationPool -value Site1AppPool
これを実行すると、正しく動作しているように見えますが、サイトを実行すると、次のエラーが発生します。
Configuration Error
**Description**: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
**Parser Error Message**: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 13: ASP.NET to identify an incoming user.
Line 14: -->
Line 15: <authentication mode="Windows" />
Line 16: <!--
Line 17: The <customErrors> section enables configuration
その後、IIS でアプリケーションを削除して手動で再作成すると、サイトは正常に動作します。私が欠けているものを教えてもらえますか?