473,327 Members | 1,896 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,327 software developers and data experts.

Redirect not working first time in classic ASP

I have a simple page with a form in it that gets posted to the following ASP

<%@ language="javascript" %>

<%
var login_success_page = "../intro.asp";
var login_failed_page = "../failed.asp";

// some db related code here

if (bError) {
Session("auth") = 0;
Response.Redirect(login_failed_page);
} else {
Session("auth") = 1;
Response.Redirect(login_success_page);
}
If I, in the form, I enter the appropriate information I get to the
intro page though if I don't enter the appropriate information I don't
get to the fail page. But if I click back to the form page from the
intro page and enter inappropriate information I do get the fail page.

I don't understand why it's not working the first time. If I hard code
the full path to failed .asp or use Server.MapPath("../") +
"failed.asp"; I get an error that reads "Object Moved The object may be
found here."

Andrew Poulos
Jan 8 '07 #1
1 6389

"Andrew Poulos" <ap*****@hotmail.comwrote in message
news:45***********************@per-qv1-newsreader-01.iinet.net.au...
>I have a simple page with a form in it that gets posted to the following
ASP

<%@ language="javascript" %>

<%
var login_success_page = "../intro.asp";
var login_failed_page = "../failed.asp";

// some db related code here

if (bError) {
Session("auth") = 0;
Response.Redirect(login_failed_page);
} else {
Session("auth") = 1;
Response.Redirect(login_success_page);
}
If I, in the form, I enter the appropriate information I get to the intro
page though if I don't enter the appropriate information I don't get to
the fail page. But if I click back to the form page from the intro page
and enter inappropriate information I do get the fail page.

I don't understand why it's not working the first time. If I hard code the
full path to failed .asp or use Server.MapPath("../") + "failed.asp"; I
get an error that reads "Object Moved The object may be found here."
Consider that a redirect is implemented as a response to one request that
contains an instruction to "request it from [here] instead." In absence of
cache-control headers the browser is free to cache the initial response.
This is why an ASP script that posts to itself and conditionally redirects
is not a great design for a login mechanism: anything that caches a redirect
effectively bypasses ASP processing.

It's possible to append a date serial value for a dummy parameter to the URL
passed to Response.Redirect, as a "cache killer" for authentication purposes
it's a weak design. Instead, write a function that checks whether the user
has authenticated *and* generates your login page if not, in the context of
the original request. If the original request's method was "POST", the
function should copy any form values that were posted to it, to hidden
inputs in the login form, so that user input is not lost by authentication.
Then store the function in a file, server-side include that file in every
protected ASP page, and call the function before writing any other content
to the response.
-Mark

Andrew Poulos

Jan 9 '07 #2

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

Similar topics

3
by: Dunc | last post by:
I've got a Web page written in C#, and when it runs and the user presses enter, it submits the first button on the form. As you'd expect. I want the system to redirect to a different page when a...
6
by: Peter Row | last post by:
Hi, I am writing a DLL in VB.NET that implements IHttpHandler.ProcessRequest. This code calls a sub and I need to know if that sub did a response redirect or not. Specifically I need to know...
6
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
2
by: Ivan Lam | last post by:
Hi all, Thanks for reading my post!!! I am facing a problem that I cannot redirect StandartOutput and StandardInput at the same time without closing the executive. Actually, I have a...
16
by: TB | last post by:
Hi all: If you think that the following comments are absolute amateurish, then please bear with me, or simply skip this thread. A couple of months back I made the decision to initiate a...
4
by: Vi | last post by:
Hi, I have an <asp:Button> control on a page. When it is clicked, I run a db stored procedure and then I want to go to the next page by executing a Response.Redirect("NextPage.aspx?id=" + myID)....
9
by: KenLee | last post by:
I made an application which includes classic asp page and asp.net page. when I tried to redirect from classic asp page to asp.net 2.0 page, it works under my local IIS directory. ex) <a...
3
by: alasdair.stirling | last post by:
Dear All, I am new to ASP/ASP.Net and am trying to workout the exact meaning of some old ASP Classic code. Can anyone please explain the meaning of the following line of code: ...
5
by: David | last post by:
Hi all, Using C#.NET 1.1 I am progressing on my URL ReWriting quite well, but have a slight problem. My server will not have real paths, just virtual, which is generated from a database....
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
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)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
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.