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 like this:
Code:
Protected Overrides Sub OnInit(ByVal e As EventArgs)
MyBase.OnInit(e)
InitializeComponent()
End Sub
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> _
Private Sub InitializeComponent()
AddHandler Me.Load, AddressOf Page_Load
End Sub
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)
'Removed "Handles MyBase.Load"
End Sub
I have not made that change in the code for SiteHeader. I am now using this fix:
Code:
If Not (TypeOf context.User Is SitePrincipal) Then
id = New SiteIdentity(Context.User.Identity.Name)
Else
id = CType(context.User.Identity, SiteIdentity)
End If
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?