Pages settings don’t work for pre-compiled ASP.Net applications
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.
<pages validateRequest="false" enableEventValidation="false" enableViewStateMac="false" viewStateEncryptionMode="Never">
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 Precompilation Overview
https://msdn.microsoft.com/en-us/library/bb398860.aspx
See you next time,
Wei Zhao
Comments
- Anonymous
July 18, 2011
Thanks you!http://www.bigc24h.com - Anonymous
December 20, 2012
Good to know! - Anonymous
March 22, 2014
Thank you very much, great article.--------------End--------tudailoan.com - Anonymous
October 09, 2014
Thank You! Save me a lot of time. - Anonymous
November 09, 2014
Thank you very much! This article save me a lot of time.http://thanhnt.com