Solved

HttpContext.User Problems.

Posted on 2007-03-21
8
348 Views
Last Modified: 2012-05-05
I'm having a problem with the HttpContext.User property. I notice this property has an Identity object with an IsAuthenticated property. All of this is ReadOnly though. At what point do I ever get the opportunity to set these values?

I am avoiding the default MembershipProvider model of ASP.NET 2.0 for multiple reasons, and even if I did persue it, I don't see how these values are set. I want to check the User.Identity.IsAuthenticated property during an HttpModule, and the IsAuthenticated needs to be true or false based on whether the user is properly logged in (using custom forms authentication).
0
Comment
Question by:derekthornton
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 27

Expert Comment

by:Sammy
ID: 18769069
in order for the HttpContext.User to be set, the ControlPrincipal flag will HAVE to be set
here is some examples on msdn
http://msdn2.microsoft.com/en-us/library/system.web.httpcontext.user.aspx

0
 
LVL 27

Accepted Solution

by:
Sammy earned 500 total points
ID: 18769089
0
 
LVL 2

Author Comment

by:derekthornton
ID: 18769398
I don't understand. all it shows is how to make objects with those flags, not actually how to set them....
0
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
LVL 2

Author Comment

by:derekthornton
ID: 18769424
(this is not how the final code will work, it's just a test)
Following the example, I'm applying the flag to a method and it won't let me compile, it says it is still readonly..

        ''' <summary>
        ''' Authenticates the calling http request and validates the member.
        ''' </summary>
        ''' <param name="sender"></param>
            ''' <param name="e"></param>
            <SecurityPermissionAttribute(SecurityAction.RequestOptional, ControlPrincipal:=True)> _
  Public Sub AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
                  HttpContext.Current.User.Identity.IsAuthenticated = True
            End Sub
0
 
LVL 27

Expert Comment

by:Sammy
ID: 18787708
Derek,
did you figure it out or you still need help?

0
 
LVL 2

Author Comment

by:derekthornton
ID: 18788942
I think I've figured it out. It's a little awkward, how Microsoft chose to implement this system, though. Thank you very much for the flags help.
0
 
LVL 2

Author Comment

by:derekthornton
ID: 18789059
Hrnm, Actually I am still confused.

I've figured out I can use FormsAuthentication.SetAuthCookie to set the Identity in the User control. . but it doesn't seem to work as intended..

            FormsAuthentication.SetAuthCookie(Me.UserName.Text, True)
            FormsAuthentication.RedirectFromLoginPage(Context.User.Identity.Name, True)

Doesn't seem to pass the username properly.. Yet it should control the IPrincipal Object, Right?
0
 
LVL 27

Expert Comment

by:Sammy
ID: 18795266
>>Yet it should control the IPrincipal Object, Right?
yes that is correct.
when  you say it doesnt work as intended, what do you mean? what do you expect to see and what actually happens?

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question