[英]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.