我有点困惑。我尚未明确设置 Web.config
,因此 此 MSDN 页面 表示它应该默认为自动
。 此 MSDN 页面 表示 Auto
应该如果控件通过调用 RegisterRequiresViewStateEncryption
方法请求加密,则会导致视图状态信息被加密。但是,我的控件都没有调用该方法。所以看起来我的视图状态实际上不应该被加密。
但是,当我将视图状态复制/粘贴到各种 在线 视图状态 解码器,我被告知视图状态序列化数据无效。那么,我的视图状态是否已加密?有什么明显的方法可以告诉吗?默认 ASP.net 行为是否已更改为默认对视图状态进行编码,除非禁用它?
I'm a little confused. I haven't explicitly set the Web.config <pages ViewStateEncryptionMode="Always" />
, and so this MSDN page says that it should default to Auto
. This MSDN page says that Auto
should cause the viewstate information to be encrypted if a control requests encryption by calling the RegisterRequiresViewStateEncryption
method. But, none of my controls call that method. So it looks like my viewstate should, in fact, not be encrypted.
However, when I copy/paste the viewstate into one of the various online viewstate decoders, I'm told that the viewstate serialized data is invalid. So, is my viewstate encrypted or not? Is there some obvious way to tell? Has the default ASP.net behaviour changed to encode the viewstate by defualt unless you disable it?
发布评论
评论(3)
如果将其设置为“Always”或“auto”,则所有控件状态都将被加密。所有调用RegisterRequiresViewStateEncryption视图状态的控件都将被加密,与“Auto”/“Always”无关。如果您的“自定义控件”需要加密,请调用此方法。
请参阅 MSDN
If its set to Always or auto, all control state would be encrypted.All controls calling
RegisterRequiresViewStateEncryption
view state would be encrypted ir-respective of Auto/Always. If your 'custom control' needs encryption call this.See this on MSDN
强制打开它,看看解码器是否会出现相同的错误。
强制关闭,看看现在是否可以解码。
我想这会给你你正在寻找的答案。
Force it on, see if you get the same error from a decoder.
Force it off, see if it now decodes.
I think that will give you the answer you're looking for.
默认设置可以在 machine.config 中找到,它是所有 Web 应用程序的通用超级配置。使用您的 web.config 您可以覆盖它。您可以打开您的网站之一并查看内部。
在这里你可以找到machine.config:
The default settings can be found on your machine.config, which is a general super config for all your web apps. with your web.config you can overwrite it. you can open one of your website and look inside.
Here you can find the machine.config: