473,320 Members | 1,883 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Passing variable between asp login page and the redirected page

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?????????

Nov 1 '07 #1
2 1612
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
SHi All
S>
SI have an asp.net 2.0 web with a standard login control
S>
SI want to pass some extra variables to the redirected page after the
Ssuccessful login
S>
SI just can't get it to work. help much appreciated
S>
S---------------------------------------------------------------------
S----------------
S>
SProtected Sub Login1_Authenticate(ByVal sender As Object, ByVal e As
SSystem.Web.UI.WebControls.AuthenticateEventArgs) Handles
SLogin1.Authenticate
S>
SContext.Items.Clear()
S>
SContext.Items.Add("UserNamevalue", Me.Login1.UserName)
S>
SContext.Items.Add("mydbkeyvalue", 2)
S>
SFormsAuthentication.RedirectFromLoginPage("steve" , False)
S>
SServer.Transfer("~/memberpages/demos.aspx", True)
S>
SEnd If
S>
SCatch ex As Exception
S>
SResponse.Write(ex.Message)
S>
SEnd Try
S>
SEnd Sub
S>
S---------------------------------------------------------------------
S-------------------------------------------------------------
S>
SIn a link button onclick event on the demos.aspx
S>
SMe.lblsamupdate.Text = "Context " &
SContext.Items("UserNamevalue").ToString
S>
SI get error 'Object reference not set to an instance of an object'
S>
SWhy?????????
S>
Nov 1 '07 #2
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?????????
Nov 1 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Paul | last post by:
I want to use sessions to cover myself in case the user switches off cookies so I am passing the session ID manually through a hidden input field. This is what I have so far. index.php page...
1
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
1
by: Nick Whitelegg | last post by:
Hello, I'm having an odd problem with combining an authentication session variable with header() redirection. Basically I have an authentication script which checks a username/password. If the...
3
by: Geoff Winsor | last post by:
Hi, I am experiencing a problem with recalling a session variable which stores whether a person is logged in to a "members only" section of a website. This area of the site has been working...
7
by: Wade Wegner | last post by:
Hello, I have been desperately trying to programmatically authenticate a windows user, create their credentials, and then redirect them to a different server while passing the credentials at the...
7
by: Trollpower | last post by:
Hello NG, i need to know how i can pass parameters to the loginpage if i use authentication mode Forms. I need to pass different paramaters, such as a different redirection url, strings and...
9
by: dana lees | last post by:
Hello, I am developing a C# asp.net application. I am using the authentication and authorization mechanism, which its timeout is set to 60 minutes. My application consists of 2 frames - a...
7
by: Alan Silver | last post by:
Hello, Sorry this is a bit wordy, but it's a pretty simple question... I have a web site, http://domain/ which is a public site, part of which (http://domain/a/) is protected by forms...
3
by: benoypaul | last post by:
I have created a php script for login using session variables in php . After checking the login information , I redirected to another page using following scripts ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.