I have an object, named SiteIdentity, that implements IIdentity. I have
added additional properties to this class, Email for instance. I am using
forms authentication.
In the code behind class for a webform, I try to cast from the HttpContext
identity object to my SiteIdentity object, but I get an error that reads
"Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then
Response.Write( Ctype( context.User.Identity,
MySite.Framework.Security.SiteIdentity).Email )
...
What am I missing?
Thanks,
Craig Buchanan 6 1747
Hi,
have you assigned your custom principal/identity object to the
HttpContext.User on every request?
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:OI****************@tk2msftngp13.phx.gbl...
I have an object, named SiteIdentity, that implements IIdentity. I have
added additional properties to this class, Email for instance. I am using
forms authentication.
In the code behind class for a webform, I try to cast from the HttpContext
identity object to my SiteIdentity object, but I get an error that reads
"Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then
Response.Write( Ctype( context.User.Identity,
MySite.Framework.Security.SiteIdentity).Email )
...
What am I missing?
Thanks,
Craig Buchanan
the error means that context.User.Identity is not a
MySite.Framework.Security.SiteIdentity. where is your code that sets
SiteIdenity to one of your objects.
-- bruce (sqlwork.com)
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:OI**************@tk2msftngp13.phx.gbl... I have an object, named SiteIdentity, that implements IIdentity. I have added additional properties to this class, Email for instance. I am using forms authentication.
In the code behind class for a webform, I try to cast from the HttpContext identity object to my SiteIdentity object, but I get an error that reads "Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then Response.Write( Ctype( context.User.Identity, MySite.Framework.Security.SiteIdentity).Email ) ...
What am I missing?
Thanks,
Craig Buchanan
Teemu-
Does it need to be on *every* request? How about just on the
Global_AcquireRequestState method the of the global.asax?
Thanks,
Craig
"Teemu Keiski" <jo****@aspalliance.com> wrote in message
news:%2******************@TK2MSFTNGP12.phx.gbl... Hi,
have you assigned your custom principal/identity object to the HttpContext.User on every request?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist
"Craig Buchanan" <so*****@somewhere.com> wrote in message news:OI****************@tk2msftngp13.phx.gbl... I have an object, named SiteIdentity, that implements IIdentity. I have added additional properties to this class, Email for instance. I am using forms authentication.
In the code behind class for a webform, I try to cast from the HttpContext identity object to my SiteIdentity object, but I get an error that reads "Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then Response.Write( Ctype( context.User.Identity, MySite.Framework.Security.SiteIdentity).Email ) ...
What am I missing?
Thanks,
Craig Buchanan
bruce-
looks like i'm only doing this on an actual database authentication. i'm
not doing anything if it is a stored asp.net auth. cookie.
where should i be setting the siteidentity in this case?
craig
"bruce barker" <no***********@safeco.com> wrote in message
news:OF****************@TK2MSFTNGP12.phx.gbl... the error means that context.User.Identity is not a MySite.Framework.Security.SiteIdentity. where is your code that sets SiteIdenity to one of your objects.
-- bruce (sqlwork.com)
"Craig Buchanan" <so*****@somewhere.com> wrote in message news:OI**************@tk2msftngp13.phx.gbl... I have an object, named SiteIdentity, that implements IIdentity. I have added additional properties to this class, Email for instance. I am
using forms authentication.
In the code behind class for a webform, I try to cast from the
HttpContext identity object to my SiteIdentity object, but I get an error that reads "Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then Response.Write( Ctype( context.User.Identity, MySite.Framework.Security.SiteIdentity).Email ) ...
What am I missing?
Thanks,
Craig Buchanan
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:uU***************@tk2msftngp13.phx.gbl... bruce-
looks like i'm only doing this on an actual database authentication. i'm not doing anything if it is a stored asp.net auth. cookie.
where should i be setting the siteidentity in this case?
In Application_AuthenticateRequest.
--
John Saunders
John.Saunders at SurfControl.com
When the user logs in correctly the Principal object is stored in Session.
I use Global_AcquireRequestState to set the context to my custom Principal.
In my BasePage I cast the CurrentUser to my Principal.
Then all my properties are available in my custom Identity.
--
Joe Fallon
"Craig Buchanan" <so*****@somewhere.com> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl... Teemu-
Does it need to be on *every* request? How about just on the Global_AcquireRequestState method the of the global.asax?
Thanks,
Craig
"Teemu Keiski" <jo****@aspalliance.com> wrote in message news:%2******************@TK2MSFTNGP12.phx.gbl... Hi,
have you assigned your custom principal/identity object to the HttpContext.User on every request?
-- Teemu Keiski MCP, Microsoft MVP (ASP.NET), AspInsiders member ASP.NET Forum Moderator, AspAlliance Columnist
"Craig Buchanan" <so*****@somewhere.com> wrote in message news:OI****************@tk2msftngp13.phx.gbl... I have an object, named SiteIdentity, that implements IIdentity. I have added additional properties to this class, Email for instance. I am
using forms authentication.
In the code behind class for a webform, I try to cast from the
HttpContext identity object to my SiteIdentity object, but I get an error that reads "Specified cast not valid". Here's the code:
If context.User.Identity.IsAuthenticated Then Response.Write( Ctype( context.User.Identity, MySite.Framework.Security.SiteIdentity).Email ) ...
What am I missing?
Thanks,
Craig Buchanan
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tim Mulholland |
last post by:
I have created my own IIdentity class (actually inherited from
GenericIdentity) to contain lots of extra useful information to be passed
around with the user's basic information.
The class...
|
by: Craig Buchanan |
last post by:
I have an object, named SiteIdentity, that implements IIdentity. I have
added additional properties to this class, Email for instance. I am using
forms authentication.
In the code behind class...
|
by: Spondishy |
last post by:
Hi,
I'm attempting to extend IIdentity to enable me to have more
information on the user (email etc) and store it in a cookie. I assume
I am extending the correct object (but if not shout up).
...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |