Invalid Cast Exception with Nested Master Pages

System.InvalidCastException is apparently quite a common error in Nested Master Pages. Quite frankly, the problem seems to be completely random:

I solved my particular problem by adding batch="false" to the compilation tag:

This has some implication on performence and you can read more about it here.

Update: 2 weeks later I was still unable to find a solution to the problem. It sounds to me like a bug in ASP.NET Web Forms.

Leave Comment

Your email address will not be published.

Please type the characters of this captcha image in the input box

Please type the characters of this captcha image in the input box