Solved

HttpContext.User Problems.

Posted on 2007-03-21
8
344 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
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
ScreenConnect 6.0 Free Trial

Explore all the enhancements in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 
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

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

823 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