Solved

HttpContext.User Problems.

Posted on 2007-03-21
8
346 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
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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

756 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