473,289 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,289 software developers and data experts.

Specified cast is not valid problem...

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
3 2155
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
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


"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Tao | last post by:
I just upgraded .NET framework to 1.1 and VS.Net to 2003 version and tried to test it out. I created an ASP.NET project using the wizard and tried to run it by hitting "F5". I got an exception:...
6
by: Raj | last post by:
I have a c# program in which I used cast. That worked perfectly on .Net platform 1.0. When I moved to .Net 2003, I am getting the execption "Specified cast is not valid". I have not made any...
1
by: Ron Holmes | last post by:
I posted this question on the Crystal Reports Support site and I am still waiting for an answer. Using Crystal Reports 9.0 Developer Full edition: My Crystal report .RPT file has a Picture box...
3
by: PK9 | last post by:
I am looking for assistance in pinpointing the cause of the following exception. I am getting a "Specified Cast is not valid" exception on my page. I am trying to populate a datagrid. One of my...
2
by: Fabian | last post by:
Hi, I work with asp.net 2.0 and I have a intermittent error, only happens a few times a day. In the page I evaluate a Query String and then I get data form a database. The code snipped: ...
0
by: QA | last post by:
I am using a Business Scorecard Accelarator in a Sharepoint Portal 2003 using SQL Server 2005 I am getting the following error: Error,5/7/2005 10:50:14 AM,580,AUE1\Administrator,"Specified cast is...
0
by: Alan Z. Scharf | last post by:
this question in datagrid group for several days with no repsonse. I'm hoping for an answer her because of greater activity in this group. No cross-posting intended. Thanks....
0
by: df | last post by:
I'm seeing a strange problem in the Web App config tool: After creating a role and a user, going back to the Security tab home page, I get a "Specified cast is not valid" error. I've set up my...
1
by: planet | last post by:
Hi, I wish I can solve this problem not having recode the sub. Here is goes: I got this error' specified cast is not valid' at the second line. from the code Sub...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: marcoviolo | last post by:
Dear all, I would like to implement on my worksheet an vlookup dynamic , that consider a change of pivot excel via win32com, from an external excel (without open it) and save the new file into a...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.