473,396 Members | 2,070 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,396 software developers and data experts.

Re-authenticate prior to server.transfer

I am posting a form with data which has timed-out and forced a login. I
assumed that the following code would re-authenticate the session
(assuming the supplied userName and password are correct) but it does
not. Can anyone suggest the solution?

if FormsAuthentication.Authenticate(tbUserName.Text, tbPassword.Text) then
FormsAuthentication.SetAuthCookie(tbUsername.Text, false)
Server.Transfer("destinationPage.aspx", true)

'This works, but doesn't transfer the form data.
'FormsAuthentication.RedirectFromLoginPage(tbUsern ame.Text, false)
else
lblMessage.Text = "<font color=red>Sorry, " & _
"invalid username or password!</FONT><P>"
end if

Nov 19 '05 #1
2 1481
To persist a cookie, you must allow a response to get back to the client,
which is what the RedirectFromLoginPage does. The Server.Transfer transfers
page execution at the server level, not the client level, so your auth
cookie never gets to the client for your required authentication.

You'll need to find a way to persist your form values using a
response.redirect, not a server.transfer, using this method. Perhaps save
this data in the session, DB or other means.

--

- Paul Glavich
ASP.NET MVP
ASPInsider (www.aspinsiders.com)
"Alfred Salton" <al***********@hotmail.com> wrote in message
news:2005021415522216807%alfredsalton@hotmailcom.. .
I am posting a form with data which has timed-out and forced a login. I
assumed that the following code would re-authenticate the session
(assuming the supplied userName and password are correct) but it does
not. Can anyone suggest the solution?

if FormsAuthentication.Authenticate(tbUserName.Text, tbPassword.Text) then
FormsAuthentication.SetAuthCookie(tbUsername.Text, false)
Server.Transfer("destinationPage.aspx", true)

'This works, but doesn't transfer the form data.
'FormsAuthentication.RedirectFromLoginPage(tbUsern ame.Text, false)
else
lblMessage.Text = "<font color=red>Sorry, " & _
"invalid username or password!</FONT><P>"
end if

Nov 19 '05 #2
On 2005-02-15 05:18:18 -0700, "Paul Glavich [MVP ASP.NET]"
<gl**@aspalliane.com-NOSPAM> said:
To persist a cookie, you must allow a response to get back to the client,
which is what the RedirectFromLoginPage does. The Server.Transfer transfers
page execution at the server level, not the client level, so your auth
cookie never gets to the client for your required authentication.

You'll need to find a way to persist your form values using a
response.redirect, not a server.transfer, using this method. Perhaps save
this data in the session, DB or other means.


So I'd like to re-establish the authentication on the server - surely
this is possible. The server already knows the ultimate destination
URL, the form data and the user credentials.
Nov 19 '05 #3

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

Similar topics

1
by: Nel | last post by:
I have a question related to the "security" issues posed by Globals ON. It is good programming technique IMO to initialise variables, even if it's just $foo = 0; $bar = ""; Surely it would...
4
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as...
1
by: Chris | last post by:
Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm going wrong? Thanks in advance and sorry again...
11
by: James | last post by:
My form and results are on one page. If I use : if ($Company) { $query = "Select Company, Contact From tblworking Where ID = $Company Order By Company ASC"; }
4
by: Alan Walkington | last post by:
Folks: How can I get an /exec'ed/ process to run in the background on an XP box? I have a monitor-like process which I am starting as 'exec("something.exe");' and, of course the exec function...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.