Discussion Locked

HTTP 404 Error when redirecting

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have some SUBMIT buttons which cause the following to run:

if NOT isempty(Request.Form("NewReport")) then
strRedirect = "./FieldSelection.asp?ViewName" & Request.Form("ViewName")
Response.Redirect strRedirect
elseif NOT isempty(Request.Form("ExistingReport")) then
strRedirect = "./AmendReport.asp?ReportName=" & Request.Form("ReportName")
Response.Redirect strRedirect
elseif NOT isempty(Request.Form("Home")) then
Response.Redirect "../default.asp"
end if

Unfortuenately, whenI press a button I get an http 404 error stating the page cannot be found. The redirects work if they are outside the button code then the redirects work.

Any ideas?

3 replies

by nikki96

You don't mention the application, so I'll assume it's on a web page.
VBScript/ASP runs on the server. Once the page has been passed to the client, VBScript will only run on the client if it's IE. You are using server side script here that will runwhen a button is clicked (thus, tries to run on the client). You can't do that. Response.Redirect can only be used before any output has been written to the client.

Use javascript or put this code on the page the form submits to so it runs after the form is submitted but before output is written to the client.

This discussion is closed to new replies.