I tried to add broken test code by creating a third partial file in addition to MyPage.aspx and MyPage.aspx.cs and MyPage.aspx.designer.cs. I named my third file MyPage.aspx.TEST.cs
In the partial file MyPage.aspx.TEST.cs, I wrote the following:
protected override void OnInit(EventArgs e) { Page.LoadComplete += RunTest; base.OnInit(e); }
The code compiles, and then I decompile the code, and there it is, I see the OnInit override and the RunTest method.
But when I execute the page, the event is not logged, does not fire, and cannot set a breakpoint.
I transfer this code from the partial class MyPage.aspx.TEST.cs to the partial file MyPage.aspx.cs and event registers and it is executed. Stranger, when I decompile the assembly and make diff, the class seems to decompile the same code.
Possible hints that may not be related:
- The page uses autoeventwireup = "true" (I still get the same behavior if I try to register my event in my Page_LoadComplete)
- An application is a web application (i.e. uses a proj file)
- The partial file is compiled (and if I introduce errors in the partial file, this will prevent compilation, so I know for sure that the partial file has been compiled)
- I get the same result using different events (PreRender, etc.)
source share