2005-FormsAuthentication, Httpcontext.current.user is always nothi

N

ns

I am using visual studio 2005, i manually addded global.asax.vb and changed
global.asax to use the code behind.

When i step into the authenticate request, i get the
HttpContext.current.user as nothing always.

AM i missing anyhting ?, has the implementation of forms authentication
changed in
Visual studio 2005.

What are the things i should look at.

I am always getting HttpContext.current.User as nothing.




Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Web.SessionState
Imports System.Security.Principal
Public Class [Global]
Inherits System.Web.HttpApplication

Private Sub Global_AuthenticateRequest(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.AuthenticateRequest
Dim UserName As String = ""

Try
UserName = HttpContext.Current.User.Identity.Name.ToString
Catch ex As Exception

End Try

End Sub
End Class
 
C

Cowboy \(Gregory A. Beamer\)

Are you using Windows Authentication? If not, the HttpContext.current.user
is the anonymous user, as that is what windows is using.

If you are using forms authentication, you will want to set up some form of
Membership. THe Membership provider model, custom or standard, is fairly
decent for this. Still will not yield something on HttpContext.current.user,
but you will be able to find info on the Profile object from Membership.
 
D

Duy Lam

ns said:
I am using visual studio 2005, i manually addded global.asax.vb and changed
global.asax to use the code behind.

When i step into the authenticate request, i get the
HttpContext.current.user as nothing always.

AM i missing anyhting ?, has the implementation of forms authentication
changed in
Visual studio 2005.

What are the things i should look at.

I am always getting HttpContext.current.User as nothing.




Imports Microsoft.VisualBasic
Imports System
Imports System.Web
Imports System.Web.SessionState
Imports System.Security.Principal
Public Class [Global]
Inherits System.Web.HttpApplication

Private Sub Global_AuthenticateRequest(ByVal sender As Object, ByVal e
As System.EventArgs) Handles Me.AuthenticateRequest
Dim UserName As String = ""

Try
UserName = HttpContext.Current.User.Identity.Name.ToString
Catch ex As Exception

End Try

End Sub
End Class


You should read through ASP.NET security model at
http://msdn2.microsoft.com/en-us/library/yedba920(VS.80).aspx. Or see a
quick tutorial at
http://msdn2.microsoft.com/en-us/library/xdt4thhy(VS.80).aspx
 
N

ns

I am usingit for Oracle, also the interesting is that i am able to access the
Httpcontext.current.user in the Page, but i the global.asax it is always
nothing.

I have already developed the code in 2003, which is working fine.
Now the new project is developed in 2005, and am copying the same code.
I don't understand why, i can't access it in global.asax, as i need to add
roles.

I understand that on the first request it will be nothing, but it is nothing
even after authentication and on every subsequent request, and at the same
time i am able to
access httpcontext in the other page except in global.asax.

I don't want to go for provider model.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top