用户特定的IIS配置

时间:2018-11-29 18:31:06

标签: visual-studio iis

MyProject> Properties> Web下,有一个选项“将服务器设置应用于所有用户”将IIS配置存储在MyProject.csproj.user中。

但是,似乎没有办法设置默认值。意味着克隆项目的任何人都必须自定义这些设置。

使用用户特定的IIS设置时是否可以设置默认值?

我尝试使用环境变量,但是Visual Studio抱怨它无法为http://$(API_HOST):$(API_PORT)/

创建IIS绑定。

1 个答案:

答案 0 :(得分:1)

您需要设置什么设置?这是一个重要的细节。 大部分配置都可以在web.config文件中设置,但该文件具有专门用于IIS配置的“ system.webServer”部分。

示例:

<system.webServer>
   <defaultDocument enabled="true">
      <files>
         <add value="Default.htm" />
         <add value="Index.htm" />
         <add value="Index.html" />
      </files>
   </defaultDocument>
   <directoryBrowse enabled="true" />
   <httpErrors>
      <error statusCode="404" prefixLanguageFilePath="%SystemDrive%\inetpub\custerr" path="my_custom_404.htm" />
   </httpErrors>
   <security>
      <authentication>
         <anonymousAuthentication enabled="true" userName="IUSR" />
         <basicAuthentication />
         <clientCertificateMappingAuthentication />
         <digestAuthentication />
         <iisClientCertificateMappingAuthentication />
         <windowsAuthentication />
      </authentication>
      <requestFiltering>
         <fileExtensions allowUnlisted="true" applyToWebDAV="true" />
         <verbs allowUnlisted="true" applyToWebDAV="true" />
         <hiddenSegments applyToWebDAV="true">
            <add segment="Web.config" />
         </hiddenSegments>
      </requestFiltering>
   </security>
   <staticContent lockAttributes="isDocFooterFileName">
      <mimeMap fileExtension=".mp3" mimeType="otect/stream" />
   </staticContent>
</system.webServer>

来源: https://docs.microsoft.com/en-us/iis/configuration/system.webserver/