I have searched the forum for answer to my problem some sound similar but are not the same, my problem is: (I know this looks a bit long but bear with me!!)
E.g Using MyAccount.aspx (
vb version)
When i first built the solution the page ran with out a problem after modifying the site a bit and rebuilding a few times I am getting 'Specified cast is not valid.' When I try to submit changes on MyAccount.aspx.
I understand that PhilePage is Inherited and this types Context.user as the SitePrincipal, which works fine when I first go to MyAccount.aspx (not postback), but fails when I submit.
I put a break point in PhilePage.
vb in the Load sub, when I first got to MyAccount.aspx the breakpoint is hit, and context.user is initialized and all is fine. On submit though the breakpoint is not hit and the code fails with the (very annoying!) 'Specified cast is not valid.'
The only way I can solve this is by copying the PhilePage page_load code into top of MyAccount.aspx Page_load.
Has anyone got any suggestions as to why this happens or how I can fix it??