由于一些安全问题,我需要启用 View 状态加密。我关闭了 viewstate 和 viewstateMAC,但我需要加密包含在 __VIEWSTATE 表单参数中的“control state”字符串。
目前我的 web.config 看起来像:
<pages enableViewState="false" enableViewStateMac="false">
当我设置以下内容时,在 cassini 中,我的 View 状态被加密:
<pages enableViewState="false" enableViewStateMac="false" viewStateEncryptionMode="Always">
当我在 IIS 6 服务器上进行相同的更改时,没有任何 react 。
我看到应用程序域回收(事件:应用程序 '/LM/W3SVC/...' 位于为域 '...' 初始化的 'C:...' 中)。当我触摸 web.config 但我没有像 cassini 那样获得加密的 View 状态。我尝试过站点停止/启动、IIS 重置停止/启动、清除 ASP.NET 临时文件缓存。任何人都对需要做些什么来配置这个有什么建议吗?
最佳答案
我遇到了类似的问题,归结为如果您预编译站点,页面的 web.config 节点将被忽略。您必须在编译时设置这些设置才能使其正常工作。我知道这已经晚了一年,但我想如果其他人来这里寻找问题的解决方案,这可能是有用的信息。
关于这个的一点简介:http://blogs.msdn.com/b/asiatech/archive/2011/07/19/pages-settings-don-t-work-for-pre-compiled-asp-net-applications.aspx
My customer had a viewstate MAC validation problem. As a workaround, he wanted to disable the viewstate MAC validation before find out the final solution. However, he was still seeing the problems after added follow settings in the configuration files.
Customer’s application is a pre-compiled ASP.Net application with updatable option disabled. Looking at the code generated by compiler with above settings, we found these settings are hard coded. So, this means simply add the above setting into web.config doesn’t affect a pre-compiled application. To make this taking affect, the application has to be re-compiled.
[DebuggerNonUserCode]
private void __BuildControlTree(default_aspx __ctrl)
{
__ctrl.EnableViewStateMac = false; __ctrl.EnableEventValidation = false;
__ctrl.ViewStateEncryptionMode = ViewStateEncryptionMode.Never;
This is a by-design behavior.
关于asp.net - viewStateEncryptionMode ="Always"未加密,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7162083/