Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ns - 24 Mar 2008 16:15 GMT
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

Signature

n

Cowboy (Gregory A. Beamer) - 24 Mar 2008 17:04 GMT
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.

Signature

Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://gregorybeamer.spaces.live.com/lists/feed.rss

or just read it:
http://gregorybeamer.spaces.live.com/

*************************************************

| Think outside the box!

*************************************************
>I am using visual studio 2005, i manually addded global.asax.vb and changed
> global.asax to use the code behind.
[quoted text clipped - 30 lines]
>    End Sub
> End Class
Eliyahu Goldin - 24 Mar 2008 17:08 GMT
The problem is that the authentication principal won't get set until the
next request to the server.

If you are using the Login control, you can use the UserName property to
identify the user.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

>I am using visual studio 2005, i manually addded global.asax.vb and changed
> global.asax to use the code behind.
[quoted text clipped - 30 lines]
>    End Sub
> End Class
Duy Lam - 24 Mar 2008 17:12 GMT
> I am using visual studio 2005, i manually addded global.asax.vb and changed
> global.asax to use the code behind.
[quoted text clipped - 30 lines]
>     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

Signature

Thanks,
Duy Lam Phuong

ns - 24 Mar 2008 18:15 GMT
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.
Signature

n

> I am using visual studio 2005, i manually addded global.asax.vb and changed
> global.asax to use the code behind.
[quoted text clipped - 30 lines]
>     End Sub
> End Class

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.