Powershell-IIS上的ConvertTo-WebApplication [英] Powershell - ConvertTo-WebApplication on IIS
问题描述
我正在尝试使用Powershell将.NET 4应用程序部署到虚拟目录.我使用以下代码;
I'm trying to use powershell to deploy a .NET 4 application to a virtual directory. I use the following code;
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
当我运行它时,它似乎可以正常运行,但是在运行站点时,出现以下错误;
When I run this, it appears to work correctly, but on running the site, I get the following error;
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中删除该应用程序并手动重新创建,则该站点工作正常.你能告诉我我在想什么吗?
If I then remove the application in IIS and manually re-create it, the site works fine. Can you tell me what I am missing?
推荐答案
运行Commandlet Convert-ToWebApplication时,先前的虚拟目录条目保留在applicationhost.config中.我遇到了同样的错误.
When you run the commandlet Convert-ToWebApplication the previous virtual directory entry remains in the applicationhost.config. I ran into the same error.
更改命令以直接创建应用程序,而不是创建虚拟目录,然后将其转换.
Change your command to create the application directly rather than create a virtual directory then convert it.
New-Item IIS:\Sites\DemoSite\Site1 -physicalPath C:\Deployment\application -type Application
这篇关于Powershell-IIS上的ConvertTo-WebApplication的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!