【问题标题】:How to encrypt the connectstring section of web.config in MVC website?如何加密 MVC 网站中 web.config 的连接字符串部分?
【发布时间】:2016-09-03 23:04:25
【问题描述】:

我想加密我的 web.config 的连接字符串部分。我已尝试按照以下步骤执行此操作:

  1. 为 VS2013 打开开发者命令提示符
  2. aspnet_regiis -pef "connectionStrings" -app "/E:\New folder\WebApplication1\WebApplication1"

这是我的错误“无法为请求的配置对象创建配置文件。失败

我做了一些谷歌,但我无法理解为什么我会面临这个问题。我尝试过更改网站文件夹的权限?

我需要在 IIS 中设置网站吗? 请帮我解决这个问题。

提前致谢。

【问题讨论】:

    标签: asp.net asp.net-mvc encryption web-config connection-string


    【解决方案1】:
    <configuration>
    <configProtectedData defaultProvider="SampleProvider">
    <providers>
      <add name="SampleProvider" 
        type="System.Configuration.RsaProtectedConfigurationProvider, 
              System.Configuration, Version=2.0.0.0, Culture=neutral, 
              PublicKeyToken=b03f5f7f11d50a3a,
             processorArchitecture=MSIL"
        keyContainerName="SampleKeys" 
        useMachineContainer="true" />
    </providers>
    

    将以上部分添加到 web.config 中。

    1. 为 VS2013 打开开发者命令提示符
    2. 将目录更改为 C:\Windows\Microsoft.NET\Framework\v4.0.30319 使用 cd C:\Windows\Microsoft.NET\Framework\v4.0.30319

      1. 运行以下命令

    aspnet_regiis -pef "connectionStrings" "E:\New folder\WebApplication2\WebApplication2"

    它加密连接字符串。 :)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-05-31
      • 2012-06-18
      • 2010-12-14
      • 1970-01-01
      • 2011-08-19
      • 2018-09-23
      • 1970-01-01
      • 2011-06-21
      相关资源
      最近更新 更多