p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

aspx thread: Page.LoadControl


Message #1 by "J Donahue" <jdonahue@f...> on Mon, 8 Jul 2002 19:22:20
This isn't a critical problem but it bugs me.  I have an application that 
uses forms authentication.  Once a user logs in, they are presented with 
menu selections.  
My code for logging out is:
FormsAuthentication.SignOut()
Response.Clear()
Session.Clear()
RightPane.Controls.Add(Page.LoadControl("Authenticate/initial.ascx"))
LeftPane.Controls.Add(Page.LoadControl("Authenticate/login.ascx"))


If a user logs out, they are taken back to the login page.  If they 
hit "Refresh", it resends the information and the following error occurs:
Specified cast is not valid
[InvalidCastException: Specified cast is not valid.]
   System.Web.UI.StateBag.LoadViewState(Object state) +41
   System.Web.UI.Control.LoadViewState(Object savedState) +31
   System.Web.UI.HtmlControls.HtmlContainerControl.LoadViewState(Object 
savedState) +13
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +125
   System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +311
   System.Web.UI.Control.AddedControl(Control control, Int32 index) +291
   System.Web.UI.ControlCollection.Add(Control child) +153
   Credit._default.Page_Load(Object sender, EventArgs e) in 
N:\DIbase\credit\default.aspx.vb:95
   System.Web.UI.Control.OnLoad(EventArgs e) +67
   System.Web.UI.Control.LoadRecursive() +29
   System.Web.UI.Page.ProcessRequestMain() +724

Anyone know why I'm getting this error??  I tried clearing the Controls 
and it still errors

  Return to Index