I am working on a Brownfield application and attempting to refactor and enhance the application.
I was recently trying to add Bundling and Minification support to the application and when I added the following tag to the Master Page:
<%:Scripts.Render("~/Scripts")%>
I got an error message stating that:
"The Controls collection cannot be modified because the control contains code blocks (i.e. <%...%>)"
I looked at the code and it seems that they are inheriting from the ASP.NET Page class and overriding numerous events such as OnInit, OnPreInit, OnLoad etc. They have compiled this custom Page class into a separate assembly and most of the ASP.NET Web Form
pages are derived from it.
Whenever I attempt to access any code on these pages, I get the above error message/exception and it always seems to fail in the OnInit method such as the following code in a particula ...
Go to the complete details ...