Solved

HttpContext.User Problems.

Posted on 2007-03-21
8
337 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
  • 4
  • 4
8 Comments
 
LVL 27

Expert Comment

by:Sammy
Comment Utility
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
Comment Utility
0
 
LVL 2

Author Comment

by:derekthornton
Comment Utility
I don't understand. all it shows is how to make objects with those flags, not actually how to set them....
0
 
LVL 2

Author Comment

by:derekthornton
Comment Utility
(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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 27

Expert Comment

by:Sammy
Comment Utility
Derek,
did you figure it out or you still need help?

0
 
LVL 2

Author Comment

by:derekthornton
Comment Utility
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
Comment Utility
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
Comment Utility
>>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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

772 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now