Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing variable between asp login page and the redirected page

Reply
Thread Tools

Passing variable between asp login page and the redirected page

 
 
Steve
Guest
Posts: n/a
 
      11-01-2007
Hi All

I have an asp.net 2.0 web with a standard login control

I want to pass some extra variables to the redirected page after the successful login

I just can't get it to work. help much appreciated

-------------------------------------------------------------------------------------
Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate

Context.Items.Clear()

Context.Items.Add("UserNamevalue", Me.Login1.UserName)

Context.Items.Add("mydbkeyvalue", 2)

FormsAuthentication.RedirectFromLoginPage("steve", False)

Server.Transfer("~/memberpages/demos.aspx", True)

End If

Catch ex As Exception

Response.Write(ex.Message)

End Try

End Sub

----------------------------------------------------------------------------------------------------------------------------------

In a link button onclick event on the demos.aspx

Me.lblsamupdate.Text = "Context " & Context.Items("UserNamevalue").ToString

I get error 'Object reference not set to an instance of an object'



Why?????????

 
Reply With Quote
 
 
 
 
Michael Nemtsev, MVP
Guest
Posts: n/a
 
      11-01-2007
Hello Steve,

did you check that u have this variable in the context in receiver?

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


S> Hi All
S>
S> I have an asp.net 2.0 web with a standard login control
S>
S> I want to pass some extra variables to the redirected page after the
S> successful login
S>
S> I just can't get it to work. help much appreciated
S>
S> ---------------------------------------------------------------------
S> ----------------
S>
S> Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
S> System.Web.UI.WebControls.AuthenticateEventArgs) Handles
S> Login1.Authenticate
S>
S> Context.Items.Clear()
S>
S> Context.Items.Add("UserNamevalue", Me.Login1.UserName)
S>
S> Context.Items.Add("mydbkeyvalue", 2)
S>
S> FormsAuthentication.RedirectFromLoginPage("steve", False)
S>
S> Server.Transfer("~/memberpages/demos.aspx", True)
S>
S> End If
S>
S> Catch ex As Exception
S>
S> Response.Write(ex.Message)
S>
S> End Try
S>
S> End Sub
S>
S> ---------------------------------------------------------------------
S> -------------------------------------------------------------
S>
S> In a link button onclick event on the demos.aspx
S>
S> Me.lblsamupdate.Text = "Context " &
S> Context.Items("UserNamevalue").ToString
S>
S> I get error 'Object reference not set to an instance of an object'
S>
S> Why?????????
S>


 
Reply With Quote
 
 
 
 
=?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
Guest
Posts: n/a
 
      11-01-2007
Steve.
I don't see how you can expect this to work:

FormsAuthentication.RedirectFromLoginPage("steve", False)
Server.Transfer("~/memberpages/demos.aspx", True)

Your first line causes the browser to request the redirect page.
the second line (Server.Transfer) will never execute.

Also, you could either stick the items into a cookie(s) or put them in
Session.

-- Peter
// Abandon all hope, ye who enter here.
http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



"Steve" wrote:

> Hi All
>
> I have an asp.net 2.0 web with a standard login control
>
> I want to pass some extra variables to the redirected page after the successful login
>
> I just can't get it to work. help much appreciated
>
> -------------------------------------------------------------------------------------
> Protected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles Login1.Authenticate
>
> Context.Items.Clear()
>
> Context.Items.Add("UserNamevalue", Me.Login1.UserName)
>
> Context.Items.Add("mydbkeyvalue", 2)
>
> FormsAuthentication.RedirectFromLoginPage("steve", False)
>
> Server.Transfer("~/memberpages/demos.aspx", True)
>
> End If
>
> Catch ex As Exception
>
> Response.Write(ex.Message)
>
> End Try
>
> End Sub
>
> ----------------------------------------------------------------------------------------------------------------------------------
>
> In a link button onclick event on the demos.aspx
>
> Me.lblsamupdate.Text = "Context " & Context.Items("UserNamevalue").ToString
>
> I get error 'Object reference not set to an instance of an object'
>
>
>
> Why?????????
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
webservice call redirected to login page fredd00 ASP .Net 0 07-02-2008 07:24 PM
Passing Login Info Between ASP 3.0 and ASP.NET? aarnan@hotmail.com ASP .Net 2 12-22-2006 10:18 PM
Grabbing referrer page on a redirected error page darrel ASP .Net 4 09-29-2004 08:25 PM
:o( .... Client not redirected to login page. M O J O ASP .Net 5 09-27-2004 09:24 AM
Using Form based Authenication and still getting redirected back to the login page Irishmaninusa ASP .Net Security 0 09-23-2004 03:02 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57