Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: Re: page_load & response.redirect???


Message #1 by "jstorfa" <jstorfa@s...> on Wed, 27 Mar 2002 17:20:49
response is not an object.... Response is though...


> 
> I use windows authentication mode, in my login page, the page_load sub 
will
> determine
> weather the user is admin or regular user and then redirect them to an
> appropriate page,
> but it seems the the response.redirect("whatever.aspx") doesn't work? how
> come?
> 
> my code:
> 
> Sub Page_Load()
> 
>   'see if the user has been authenticated
>   If User.Identity.IsAuthenticated Then
> 
>     'create a reference to a WIndowsIdentity object that
>     'represents this users Indentity object
>     Dim objIdentity = CType(User.Identity, WindowsIdentity)
> 
>     'get the current WindowsIdentity object for this user
>     'this contains more specific information
>     Dim objWinIdentity = objIdentity.GetCurrent()
> 
>     'display the properties
>     'NOTE: change the group names and the machine name to suit your setup
>     msgHello.InnerHtml = "Hello <b>" & objWinIdentity.Name 
& "</b><br />" _
>                        & "The authentication method used was <b>" _
>                        & objWinIdentity.AuthenticationType 
& "</b><br />" _
>                        & "Is this a System account: <b>" _
>                        & objWinIdentity.IsSystem & "</b><br />" _
>                        & "Is this an Anonymous account: <b>" _
>                        & objWinIdentity.IsAnonymous & "</b><br />" _
>                        & "Is this a Guest account: <b>" _
>                        & objWinIdentity.IsGuest & "</b><br />" _
>                        & "Is this account a member of 
the 'Administrators'
> group: <b>" _
>                        & User.IsInRole("BUILTIN\Administrators") 
& "</b><br
> />" _
>                        & "Is this account a member of the 'Users' group:
> <b>" _
>                        & User.IsInRole("BUILTIN\Users") & "</b><br />" _
>                        & "Is this account a member of the
> 'DANDARE\TestGroup' group: <b>" _
>                        & User.IsInRole("DANDARE\TestGroup") 
& "</b><br />" _
>                        & "Is this account a member of the
> 'DANDARE\NoMembers' group: <b>" _
>                        & User.IsInRole("DANDARE\NoMembers") & "</b>"
> 
> ' note the messgae above display properly without the following added,
> otherwise the page is blank. 
> 
>   if User.IsInRole("BUILTIN\Administrators") 
>  	response.redirect("login_admin.aspx")
>  else 
> 	response.redirect("login_user.aspx")
>  end if
> 
> 
> 
>   Else
> 
>     msgHello.InnerHtml = "Hello, you were not authenticated"
> 
>   End If
> 
> End Sub
> 
> Kevin Yu
> system.data.oledb
> coop student
> Western Research Center - Natural Resource Canada
> email: kyu@n...
> phone:(780) 987-8611
> 
Message #2 by "Lewis" <lewis@t...> on Wed, 27 Mar 2002 10:38:16 -0700
Response.redirect should work - but it sends the new url to the client's
browser and then it comes back in as a new request.
I think that your code should work if you use
server.transfer("whatever.aspx") instead.

-----Original Message-----
From: jstorfa [mailto:jstorfa@s...]
Sent: Wednesday, March 27, 2002 5:21 PM
To: ASP+
Subject: [aspx] Re: page_load & response.redirect???


response is not an object.... Response is though...


>
> I use windows authentication mode, in my login page, the page_load sub
will
> determine
> weather the user is admin or regular user and then redirect them to an
> appropriate page,
> but it seems the the response.redirect("whatever.aspx") doesn't work? how
> come?
>
> my code:
>
> Sub Page_Load()
>
>   'see if the user has been authenticated
>   If User.Identity.IsAuthenticated Then
>
>     'create a reference to a WIndowsIdentity object that
>     'represents this users Indentity object
>     Dim objIdentity = CType(User.Identity, WindowsIdentity)
>
>     'get the current WindowsIdentity object for this user
>     'this contains more specific information
>     Dim objWinIdentity = objIdentity.GetCurrent()
>
>     'display the properties
>     'NOTE: change the group names and the machine name to suit your setup
>     msgHello.InnerHtml = "Hello <b>" & objWinIdentity.Name
& "</b><br />" _
>                        & "The authentication method used was <b>" _
>                        & objWinIdentity.AuthenticationType
& "</b><br />" _
>                        & "Is this a System account: <b>" _
>                        & objWinIdentity.IsSystem & "</b><br />" _
>                        & "Is this an Anonymous account: <b>" _
>                        & objWinIdentity.IsAnonymous & "</b><br />" _
>                        & "Is this a Guest account: <b>" _
>                        & objWinIdentity.IsGuest & "</b><br />" _
>                        & "Is this account a member of
the 'Administrators'
> group: <b>" _
>                        & User.IsInRole("BUILTIN\Administrators")
& "</b><br
> />" _
>                        & "Is this account a member of the 'Users' group:
> <b>" _
>                        & User.IsInRole("BUILTIN\Users") & "</b><br />" _
>                        & "Is this account a member of the
> 'DANDARE\TestGroup' group: <b>" _
>                        & User.IsInRole("DANDARE\TestGroup")
& "</b><br />" _
>                        & "Is this account a member of the
> 'DANDARE\NoMembers' group: <b>" _
>                        & User.IsInRole("DANDARE\NoMembers") & "</b>"
>
> ' note the messgae above display properly without the following added,
> otherwise the page is blank.
>
>   if User.IsInRole("BUILTIN\Administrators")
>  	response.redirect("login_admin.aspx")
>  else
> 	response.redirect("login_user.aspx")
>  end if
>
>
>
>   Else
>
>     msgHello.InnerHtml = "Hello, you were not authenticated"
>
>   End If
>
> End Sub
>
> Kevin Yu
> system.data.oledb
> coop student
> Western Research Center - Natural Resource Canada
> email: kyu@n...
> phone:(780) 987-8611
>


  Return to Index