在每个Visual Studio应用发布上重置IIS应用程序池标识权限

时间:2019-02-27 18:13:56

标签: asp.net-mvc iis permissions applicationpoolidentity visual-studio-publish

按照this questions中的说明,我可以成功更改应用程序池标识的权限

enter image description here

但是,在发布Web应用程序之后...

enter image description here

应用程序池标识已重置为“只读”

enter image description here

即使重新发布Web应用程序后,如何赋予应用程序池标识完全权限?如果我授予IUSR完全权限,也会发生相同的行为。

1 个答案:

答案 0 :(得分:1)

据我所知,如果您使用Visual Studio中的Web Deploy,则发布将通过将它们清除为父级的继承默认值来覆盖服务器上的ACL。

为避免每次发布Web应用程序时更新ACL。

您可以尝试在PublishProfiles的pubxml中添加以下命令。

 <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>

详细信息发布个人资料,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121. 
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <WebPublishMethod>MSDeploy</WebPublishMethod>
    <LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
    <LastUsedPlatform>Any CPU</LastUsedPlatform>
    <SiteUrlToLaunchAfterPublish />
    <LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
    <ExcludeApp_Data>False</ExcludeApp_Data>
    <MSDeployServiceURL>http://localhost:9825/</MSDeployServiceURL>
    <DeployIisAppPath>WebFormApplication</DeployIisAppPath>
    <RemoteSitePhysicalPath />
    <SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
    <MSDeployPublishMethod>InProc</MSDeployPublishMethod>
    <EnableMSDeployBackup>False</EnableMSDeployBackup>
    <UserName />
    <_SavePWD>False</_SavePWD>
     <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
    <PublishDatabaseSettings>
      <Objects xmlns="">
        <ObjectGroup Name="DefaultConnection" Order="1" Enabled="False">
          <Destination Path="" />
          <Object Type="DbCodeFirst">
            <Source Path="DBContext" DbContext="WebFromIdentityTest.Models.ApplicationDbContext, WebFromIdentityTest" Origin="Configuration" />
          </Object>
        </ObjectGroup>
      </Objects>
    </PublishDatabaseSettings>
  </PropertyGroup>
  <ItemGroup>
    <MSDeployParameterValue Include="$(DeployParameterPrefix)DefaultConnection-Web.config Connection String" />
  </ItemGroup>
</Project>

然后,您会发现发布该应用程序后该权限不会更改。