Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 25th, 2005, 03:21 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Specified cast is not valid @ MyProfile.aspx

I use the VB.net version
I have got an error when I log in into an account and go into a forum and click on the My profile links.

error detail
The error occurred in:
http://localhost/ThePhileVB/WebModul...MyProfile.aspx

Error Message:
Specified cast is not valid.

Error Stack:
System.InvalidCastException: Specified cast is not valid.
    Wrox.WebModules.Forums.Web.MyProfile.Page_Load(Obj ect sender, EventArgs e) in C:\wrox\ThePhileVB\WebModules\Forums\MyProfile.asp x.vb:line 70
    System.EventHandler.Invoke(Object sender, EventArgs e)
    System.Web.UI.Control.OnLoad(EventArgs e)
    System.Web.UI.Control.LoadRecursive()
    System.Web.UI.Page.ProcessRequestMain()

I have tried some of the solution that found on the forum but no luck. Hope someone can help me...
 
Old May 25th, 2005, 03:28 PM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

   Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

            ' If the user is not authenticated, redirect to the login page
            If Not Context.User.Identity.IsAuthenticated Then
                Response.Redirect("/ThePhileVB/Modules/Users/Login.aspx", True)
            End If

            ' Retrieve the current user/member

error, line 70>>myCurrUser = CType(Context.User.Identity, SiteIdentity)
            myCurrMember = New Business.Member
            myCurrMember.LoadFromUser(myCurrUser.UserId)

          ...
 
Old June 3rd, 2005, 04:58 AM
Authorized User
 
Join Date: May 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I get the same problem.

Public Class SiteIdentity
    Implements System.Security.Principal.IIdentity

Context.User.Identity As System.Security.Principal.IIdentity

They look the same type to me?!


 
Old June 28th, 2005, 06:44 PM
Authorized User
 
Join Date: Jun 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I'm having the same problem, Actually it's really strange because i tried to even cast it to itself and it didn't work?
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            If Context.User.Identity.IsAuthenticated Then

Dim id As SiteIdentity = CType(Context.User.Identity, System.Security.Principal.IIdentity)

Does anyone have an answer?

 
Old June 29th, 2005, 06:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Did you guys try the things I mentioned here:

http://p2p.wrox.com/topic.asp?TOPIC_ID=15318

Make sure you understand the "first" and "second" items.

Eric
 
Old June 30th, 2005, 12:55 PM
Authorized User
 
Join Date: Jun 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am inheriting from the base page (which i've renamed pmWorksPage) and that's where the problem is occuring.


Imports AIM.WebModules
Imports AIM.WebModules.Accounts.Business

Namespace pmworks.Web

    Public Class _default
        Inherits AIM.pmworks.Web.pmWorksPage

#Region " Web Form Designer Generated Code "



        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object

        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()

        End Sub
#End Region

        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here

            If Context.User.Identity.IsAuthenticated Then

                Dim id As SiteIdentity = CType(Context.User.Identity, SiteIdentity)
                Response.Write("Welcome " & id.name)


            Else
            End If
        End Sub

    End Class

 
Old July 20th, 2005, 11:25 AM
Registered User
 
Join Date: Jul 2005
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I tried everything mentioned here and I am still getting the same
problem.
Can anybody help please?
Ashraf

Ashraf





Similar Threads
Thread Thread Starter Forum Replies Last Post
Specified cast is not valid. ayem Visual Studio 2008 1 September 8th, 2008 09:15 PM
Specified cast is not valid surajb Crystal Reports 0 January 12th, 2007 02:03 PM
Specified cast is not valid. abstar BOOK: ASP.NET Website Programming Problem-Design-Solution 2 March 31st, 2005 03:00 PM
"Specified cast is not valid" help BaBaBooey ASP.NET 1.0 and 1.1 Basics 2 November 23rd, 2004 12:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.