I am still getting the "Specified Cast is not valid" error for SiteIdentity in SiteHeader.ascx.vb
I have built the solution by copying and modifying the code one file at a time. But the code
is 100% identical (except for namespaces).
I have modified the events for all pages (Default, Login, MyAccount) that inherit from PhilePage
Protected Overrides Sub OnInit(ByVal e As EventArgs)
'This call is required by the Web Form Designer.
Private Sub InitializeComponent()
AddHandler Me.Load, AddressOf Page_Load
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Removed "Handles MyBase.Load"
I have not made that change in the code for SiteHeader. I am now using this fix:
If Not (TypeOf context.User Is SitePrincipal) Then
id = New SiteIdentity(Context.User.Identity.Name)
id = CType(context.User.Identity, SiteIdentity)
Which seems to work, but I want to know why it isn't working (very frustrating because the
code is the same, and the Wrox.ThePhile solution is working, but mine isn't) and also
how to fix?