我应该使用什么策略来加密web.config部分?

时间:2023-01-15 09:46:10

I want to add automated encryption of some sections of web.config with following requirements:

我想添加web.config的某些部分的自动加密,具有以下要求:

  1. It should be done automatically every time application is started (I don't want to do it manually using aspnet_regiis after each config edit)
  2. 它应该在每次启动应用程序时自动完成(我不想在每次配置编辑后使用aspnet_regiis手动完成)
  3. It should automatically happen only on production environment (I need to see my values on my machine)
  4. 它应该只在生产环境中自动发生(我需要在我的机器上查看我的值)

It's not a problem to find the code for it, my question is where to put it and how to make sure it's not executed on my localhost? I tried to put it to Global.asax but I get Request is not available in this context exception there.

找到它的代码不是问题,我的问题是在哪里放置它以及如何确保它不在我的localhost上执行?我试图把它放到Global.asax但我得到的请求在这个上下文异常中不可用。

Thanks.

谢谢。

1 个解决方案

#1


3  

I would recommend setting this up as part of your deployment process.

我建议将其设置为部署过程的一部分。

Calling the encryption every time the application starts isn't a good idea because the ASP.Net App Pool will recycle itself from time to time, and that could cause problems.

每次应用程序启动时调用加密都不是一个好主意,因为ASP.Net应用程序池会不时地自行回收,这可能会导致问题。

Depending on your deployment process, you can do it through a batch file, powershell script, but it will need to be run on your production machine in question.

根据您的部署过程,您可以通过批处理文件powershell脚本执行此操作,但需要在您的生产计算机上运行它。

#1


3  

I would recommend setting this up as part of your deployment process.

我建议将其设置为部署过程的一部分。

Calling the encryption every time the application starts isn't a good idea because the ASP.Net App Pool will recycle itself from time to time, and that could cause problems.

每次应用程序启动时调用加密都不是一个好主意,因为ASP.Net应用程序池会不时地自行回收,这可能会导致问题。

Depending on your deployment process, you can do it through a batch file, powershell script, but it will need to be run on your production machine in question.

根据您的部署过程,您可以通过批处理文件powershell脚本执行此操作,但需要在您的生产计算机上运行它。