473,399 Members | 4,177 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,399 software developers and data experts.

forms identity problem

I'm receiving a "specified cast is invalid" with the following code, though
I've used the exact same code in other applications with success. Can anyone
tell me what I'm missing or if there are other factors to be considered
here?
Thanks in advance.

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

Dim objFormsID as FormsIdentity
objFormsID = User.Identity <=== specified cast
invalid
....
End Sub
========
Nov 17 '05 #1
5 1442
"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
I'm receiving a "specified cast is invalid" with the following code, though I've used the exact same code in other applications with success. Can anyone tell me what I'm missing or if there are other factors to be considered
here?
Thanks in advance.

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

Dim objFormsID as FormsIdentity
objFormsID = User.Identity <=== specified cast
invalid


So, I guess User.Identity is not a FormsIdentity.
--
John
Nov 17 '05 #2
As that reply was quite unhelpful, perhaps I have not been clear enough.
I'm curious as to why this code is used successfully in text books and has
worked in other web applications of mine, but does not work in this one. Can
anyone offer any insight as to what criteria must be met for this cast to be
made, or why this would incur the stated runtime error in one case but not
another?
Thanks in advance.

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oc****************@TK2MSFTNGP11.phx.gbl...
"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
I'm receiving a "specified cast is invalid" with the following code,

though
I've used the exact same code in other applications with success. Can

anyone
tell me what I'm missing or if there are other factors to be considered
here?
Thanks in advance.

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

Dim objFormsID as FormsIdentity
objFormsID = User.Identity <=== specified cast
invalid


So, I guess User.Identity is not a FormsIdentity.
--
John

Nov 17 '05 #3
Because in your instance, User.Identity does not reference a FormsIdentity,
but rather some other type of object. I recommend you use the debugger to
find out what kind of object it is. If you'd rather not, try
Response.Write(User.Identity.GetType().FullName), and put a REM in front of
the line which fails.

If this question is still not helpful, perhaps you could tell us what part
of it you don't understand.

--
John

"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:#$*************@TK2MSFTNGP10.phx.gbl...
As that reply was quite unhelpful, perhaps I have not been clear enough.
I'm curious as to why this code is used successfully in text books and has
worked in other web applications of mine, but does not work in this one. Can anyone offer any insight as to what criteria must be met for this cast to be made, or why this would incur the stated runtime error in one case but not
another?
Thanks in advance.

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oc****************@TK2MSFTNGP11.phx.gbl...
"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
I'm receiving a "specified cast is invalid" with the following code,

though
I've used the exact same code in other applications with success. Can

anyone
tell me what I'm missing or if there are other factors to be considered here?
Thanks in advance.

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

Dim objFormsID as FormsIdentity
objFormsID = User.Identity <=== specified cast
invalid


So, I guess User.Identity is not a FormsIdentity.
--
John


Nov 17 '05 #4
I know what type it is. It's an IIdentity.
My question was, and is, why it is able to cast an IIdentity to the
FormsIdentity variable in some cases, but not others.

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
Because in your instance, User.Identity does not reference a FormsIdentity, but rather some other type of object. I recommend you use the debugger to
find out what kind of object it is. If you'd rather not, try
Response.Write(User.Identity.GetType().FullName), and put a REM in front of the line which fails.

If this question is still not helpful, perhaps you could tell us what part
of it you don't understand.

--
John

"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:#$*************@TK2MSFTNGP10.phx.gbl...
As that reply was quite unhelpful, perhaps I have not been clear enough.
I'm curious as to why this code is used successfully in text books and has
worked in other web applications of mine, but does not work in this one. Can
anyone offer any insight as to what criteria must be met for this cast to be
made, or why this would incur the stated runtime error in one case but

not another?
Thanks in advance.

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oc****************@TK2MSFTNGP11.phx.gbl...
"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:O5**************@TK2MSFTNGP09.phx.gbl...
> I'm receiving a "specified cast is invalid" with the following code,
though
> I've used the exact same code in other applications with success. Can anyone
> tell me what I'm missing or if there are other factors to be

considered > here?
> Thanks in advance.
>
> ========
> Private Sub Page_Load(ByVal sender as System.Object, ByVal e as
> System.EventArgs) Handles MyBase.Load
>
> Dim objFormsID as FormsIdentity
> objFormsID = User.Identity <=== specified cast > invalid

So, I guess User.Identity is not a FormsIdentity.
--
John



Nov 17 '05 #5
"Darin Shaw" <da*******@NOSPAMiqmetrix.com> wrote in message
news:#2*************@TK2MSFTNGP10.phx.gbl...
I know what type it is. It's an IIdentity.
My question was, and is, why it is able to cast an IIdentity to the
FormsIdentity variable in some cases, but not others.
No, you don't know.

IIdentity is an interface. Many different classes implement IIdentity.
FormsIdentity is only one of them. GenericIdentity and WindowsIdentity are
others. Neither of the latter two are the same as FormsIdentity, so neither
can be cast to FormsIdentity.

For some reason, you're getting a different type of authentication than you
had intended. You need to follow my suggestion and either look at
User.Identity in the debugger, or write it out with Response.Write.
--
John

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:O2**************@tk2msftngp13.phx.gbl...
Because in your instance, User.Identity does not reference a

FormsIdentity,
but rather some other type of object. I recommend you use the debugger to
find out what kind of object it is. If you'd rather not, try
Response.Write(User.Identity.GetType().FullName), and put a REM in front

of
the line which fails.

If this question is still not helpful, perhaps you could tell us what part of it you don't understand.

--
John

"Darin Shaw" <da*******@iqmetrix.com> wrote in message
news:#$*************@TK2MSFTNGP10.phx.gbl...
As that reply was quite unhelpful, perhaps I have not been clear enough. I'm curious as to why this code is used successfully in text books and has worked in other web applications of mine, but does not work in this one. Can
anyone offer any insight as to what criteria must be met for this cast to
be
made, or why this would incur the stated runtime error in one case but

not another?
Thanks in advance.

"John Saunders" <john.saunders at surfcontrol.com> wrote in message
news:Oc****************@TK2MSFTNGP11.phx.gbl...
> "Darin Shaw" <da*******@iqmetrix.com> wrote in message
> news:O5**************@TK2MSFTNGP09.phx.gbl...
> > I'm receiving a "specified cast is invalid" with the following
code, > though
> > I've used the exact same code in other applications with success.

Can > anyone
> > tell me what I'm missing or if there are other factors to be

considered
> > here?
> > Thanks in advance.
> >
> > ========
> > Private Sub Page_Load(ByVal sender as System.Object, ByVal e as
> > System.EventArgs) Handles MyBase.Load
> >
> > Dim objFormsID as FormsIdentity
> > objFormsID = User.Identity <=== specified cast > > invalid
>
> So, I guess User.Identity is not a FormsIdentity.
> --
> John
>
>



Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
2
by: Senthil | last post by:
1. Created a new C# web application project 2. Change the name of webform1 to login.aspx 3. And in the .cs file change the name of the class to login, and include System.web.security namespace....
1
by: Paul Daly (MCP) | last post by:
Background: I want to be able to authenticate users whose usernames & passwords are stored in a SQL database. I only want certain pages to require authentication. I have tried to implement this...
11
by: VB Programmer | last post by:
PLEASE HELP.... I'm having trouble. In my login form after I've verified the username/password are valid I do this: Select Case iMyPrivilege Case 0 Dim arrRoles() As String = {"guest"}...
1
by: techfuzz | last post by:
I'm posting my problem experience and solution I found here for other ASP.NET developers. I have a web application that uses Forms Authentication with Active Directory to control access. In...
3
by: Martin | last post by:
Dear fellow ASP.NET programmer, I stared using forms authentication and temporarily used a <credentials> tag in web.config. After I got it working I realized this wasn't really practical. I...
7
by: - Steve - | last post by:
I have forms based authentication working, using my Active Directory for authentication. I have a web page that creates a user in active directory. When I was using IIS authentication it worked...
3
by: Harold Crump | last post by:
Greetings, I need to implement GenericPrincipal based authentication without using ASP.NET Forms Authentication. I know it is much simpler using Forms Authentication, but in this case, I have...
4
by: Matthew Roche | last post by:
Greetings: I am developing an application that uses an ASP.NET Web Forms application for its UI and ASP.NET web services for its business tier, and I am looking for assistance in improving my...
8
by: =?Utf-8?B?TFc=?= | last post by:
Hello! I am just learning about forms authentication so please excuse this basic question. I am using .NET 1.1 and C#. I have created my web.config file and my login.aspx and the associated cs...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.