Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

HttpContext.User Problems.

Posted on 2007-03-21
8
Medium Priority
?
349 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 Ageil
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 Ageil earned 2000 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 Ageil
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 Ageil
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

722 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