简体   繁体   English

用户密码错误 (WCF):在 web.config 中未正确配置用户密码

[英]User Secret Error (WCF) : User secrets are not configured correctly in the web.config

I am trying to learn how to use User Secrets.我正在尝试学习如何使用用户机密。 In a previous post I accountered some errors while applying it on App Console.在上一篇文章中,我在 App Console 上应用它时遇到了一些错误。 So I decided to use it on WCF project.所以我决定在 WCF 项目上使用它。

When I click on the project and choose User Secrets this error pops up:当我单击项目并选择用户机密时,会弹出此错误:

User secrets are not configured correctly in the web.config file
check that a reference to UserSecretsConfigBuilder has been added to
the <configBuilder> <builder> section of web config

Here is a picture of the error:这是错误的图片:

在此处输入图像描述

Here is my web.config file:这是我的web.config文件:

<?xml version="1.0" encoding="utf-8"?>
<configuration>

  <configSections>
    <section name="configBuilders"
      type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
      restartOnExternalChanges="false" requirePermission="false"/>
  </configSections>
  <configBuilders>
    <builders>
    </builders>
  </configBuilders>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.7.2"/>
    <httpRuntime targetFramework="4.7.2"/>
  </system.web>
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <!-- Pour éviter la divulgation d'informations de métadonnées, définissez les valeurs ci-dessous sur false avant le déploiement -->
          <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/>
          <!-- Pour recevoir les détails de l'exception dans les erreurs à des fins de débogage, définissez la valeur ci-dessous sur true. Pour éviter la divulgation d'informations d'exception, définissez-la sur false avant le déploiement -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <protocolMapping>
        <add binding="basicHttpsBinding" scheme="https"/>
    </protocolMapping>    
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        Pour parcourir le répertoire racine de l'application Web lors du débogage, définissez la valeur ci-dessous sur true.
        Définissez-la sur false avant le déploiement pour ne pas divulguer d'informations du dossier de l'application Web.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

Thank you very much in advance.非常感谢您提前。

These 2 links explain how to add User Secrets in .NET 4.7 projects:这 2 个链接说明了如何在 .NET 4.7 项目中添加用户机密:

TL;DR Add the following lines to your web.config: TL;DR将以下行添加到您的 web.config 中:

<configBuilders>
    <builders>
      <add name="Secrets" userSecretsFile="~/App_Data/secrets.xml" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.UserSecretsConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.UserSecrets, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    </builders>
</configBuilders>

By using the userSecretsFile property you define the location for your secrets file, you can also use userSecretsId with a GUID value (or something else, doesn't have to be a GUID), then the project will create the secrets file in:通过使用userSecretsFile属性,您可以定义秘密文件的位置,您还可以使用带有 GUID 值(或其他东西,不必是 GUID)的userSecretsId ,然后项目将在以下位置创建秘密文件:

C:\Users\[Username]\AppData\Roaming\Microsoft\UserSecrets\[YOUR GUID OR IDENTIFIER]

If you use both properties, then the userSecretsFile property will get priority.如果同时使用这两个属性,则userSecretsFile属性将获得优先权。 In your project you can right-click 'Manage User Secrets' to easily edit your User Secrets.在您的项目中,您可以右键单击“管理用户密码”以轻松编辑您的用户密码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 WCF WebRole web.config文件错误 - WCF WebRole web.config file error UnityContainer在web.config中配置 - UnityContainer configured in web.config 在web.config的Connection String中更改用户 - Changing user in Connection String of web.config 错误“未在web.config文件中配置Sanitizer提供程序。 ” - error “Sanitizer provider is not configured in the web.config file. ” 如何让用户配置在<identity impersonate="true">在 web.config 中以自己的权限执行一些代码 (ASP.NET Core)</identity> - How to get user configured at <identity impersonate="true"> in web.config to execute some code with it own privileges (ASP.NET Core) wcf web.config文件 - wcf web.config file 是否可以查看/编辑内部的WCF配置 <system.Servicemodel> 在web.config中的ASP .Net Web应用程序通过IIS管理器中的用户界面? - Is it possible to view / edit WCF configuration inside <system.Servicemodel> in web.config ASP .Net web application by user interface in IIS Manager? 存储在 Google Secret Manager 中的 DotNet 用户机密 - DotNet User secrets stored in Google Secret Manager 允许用户从Web.config获得IIS授权角色 - Allowing user to IIS Authorization roles from Web.config 无法将用户控件注册移动到嵌套的web.config中 - Unable to move User Control registration into nested web.config
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM