By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,268 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

Specified cast is not valid problem...

P: n/a
I am setting up forms authentication.

In my code I keep getting this error. Any ideas?

Error....
Server Error in '/LandOLots' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 45: ' Fires upon attempting to authenticate the use
Line 46: If Request.IsAuthenticated Then
Line 47: Dim fiIndentity As FormsIdentity = CType(User.Identity,
FormsIdentity)
Line 48: If fiIndentity Is Nothing Then Exit Sub
Line 49: Dim fatTicket As Security.FormsAuthenticationTicket =
fiIndentity.Ticket()

Source File: c:\inetpub\wwwroot\LandOLots\Global.asax.vb Line: 47

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
LandOLots.Global.Application_AuthenticateRequest(O bject sender, EventArgs
e) in c:\inetpub\wwwroot\LandOLots\Global.asax.vb:47
System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
You're trying to cast an IPrinciple object as a
System.Web.Security.FormsIdentity object. Unless IPrinciple inherits
System.Web.Security.FormsIdentity (which it doesn't), you cannot do that.

Casting can be done from like types, such as Float and Double, or from
inherited types, such as casting System.Web.Security.FormsIdentity to
System.Object, which it inherits.
--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Neither a follower nor a lender be.

"VB Programmer" <xD**********@Dont.com> wrote in message
news:uM*************@TK2MSFTNGP14.phx.gbl...
I am setting up forms authentication.

In my code I keep getting this error. Any ideas?

Error....
Server Error in '/LandOLots' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:

Line 45: ' Fires upon attempting to authenticate the use
Line 46: If Request.IsAuthenticated Then
Line 47: Dim fiIndentity As FormsIdentity =
CType(User.Identity, FormsIdentity)
Line 48: If fiIndentity Is Nothing Then Exit Sub
Line 49: Dim fatTicket As Security.FormsAuthenticationTicket =
fiIndentity.Ticket()

Source File: c:\inetpub\wwwroot\LandOLots\Global.asax.vb Line: 47

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
LandOLots.Global.Application_AuthenticateRequest(O bject sender,
EventArgs e) in c:\inetpub\wwwroot\LandOLots\Global.asax.vb:47

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032

Nov 19 '05 #2

P: n/a
Thanks as usual.

I found out that the problem was I didn't have the web.config setup for
forms auth.

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:OC****************@TK2MSFTNGP12.phx.gbl...
You're trying to cast an IPrinciple object as a
System.Web.Security.FormsIdentity object. Unless IPrinciple inherits
System.Web.Security.FormsIdentity (which it doesn't), you cannot do that.

Casting can be done from like types, such as Float and Double, or from
inherited types, such as casting System.Web.Security.FormsIdentity to
System.Object, which it inherits.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
Neither a follower nor a lender be.

"VB Programmer" <xD**********@Dont.com> wrote in message
news:uM*************@TK2MSFTNGP14.phx.gbl...
I am setting up forms authentication.

In my code I keep getting this error. Any ideas?

Error....
Server Error in '/LandOLots' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not
valid.

Source Error:

Line 45: ' Fires upon attempting to authenticate the use
Line 46: If Request.IsAuthenticated Then
Line 47: Dim fiIndentity As FormsIdentity =
CType(User.Identity, FormsIdentity)
Line 48: If fiIndentity Is Nothing Then Exit Sub
Line 49: Dim fatTicket As Security.FormsAuthenticationTicket
= fiIndentity.Ticket()

Source File: c:\inetpub\wwwroot\LandOLots\Global.asax.vb Line: 47

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
LandOLots.Global.Application_AuthenticateRequest(O bject sender,
EventArgs e) in c:\inetpub\wwwroot\LandOLots\Global.asax.vb:47

System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032


Nov 19 '05 #3

P: n/a


"VB Programmer" wrote:
I am setting up forms authentication.

In my code I keep getting this error. Any ideas?

Error....
Server Error in '/LandOLots' Application.
--------------------------------------------------------------------------------

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information
about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

Line 45: ' Fires upon attempting to authenticate the use
Line 46: If Request.IsAuthenticated Then
Line 47: Dim fiIndentity As FormsIdentity = CType(User.Identity,
FormsIdentity)
Line 48: If fiIndentity Is Nothing Then Exit Sub
Line 49: Dim fatTicket As Security.FormsAuthenticationTicket =
fiIndentity.Ticket()

Source File: c:\inetpub\wwwroot\LandOLots\Global.asax.vb Line: 47

Stack Trace:

[InvalidCastException: Specified cast is not valid.]
LandOLots.Global.Application_AuthenticateRequest(O bject sender, EventArgs
e) in c:\inetpub\wwwroot\LandOLots\Global.asax.vb:47
System.Web.SyncEventExecutionStep.System.Web.HttpA pplication+IExecutionStep.Execute()
System.Web.HttpApplication.ExecuteStep(IExecutionS tep step, Boolean&
completedSynchronously)

--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.