Object doesn't support this property or method: 'Response.Redirect

P

Peter D

I wanted to add this method to my .asp page in order to dynamically choose a
page based upon some selection criteria. It's in my .asp book and in the
online reference. Yet when I use this object, the following error returns
in the browser:

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Response.Redirect'
/testwebs/choose.asp, line 22

What is missing from my IIS libraries in order to use have this method
supported?

Thanks for any info

/peter d.
 
M

McKirahan

Peter D said:
I wanted to add this method to my .asp page in order to dynamically choose a
page based upon some selection criteria. It's in my .asp book and in the
online reference. Yet when I use this object, the following error returns
in the browser:

Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Response.Redirect'
/testwebs/choose.asp, line 22

What is missing from my IIS libraries in order to use have this method
supported?

Thanks for any info

/peter d.

What follows "Response.Redirect "?

If it's a variable then what is it's value?
 
P

Peter D

Here it is:

<%
dim strUrlName, strUrlValue
strUrlValue = Request.Form("pickUrl")
strUrlName = Left(strUrlValue,8)
if strUrlName = "" then
Response.Redirect = "index.asp"
else
Response.Redirect = "<%strUrlName>"
end if %>

PickUrl is a form in a previous page (index.asp) that is a select-list.
Based upon that selection, I want to url to the selected page. The value in
strUrlName is the 'page.asp' name, which shows in the post data just fine.
Neither works because for some reason the server thinks the method of that
reponse object is not valid ?

regards, Peter D.

------------------
 
D

diablo

<%
dim strUrlName, strUrlValue
strUrlValue = Request.Form("pickUrl")
strUrlName = Left(strUrlValue,8)
if strUrlName = "" then
Response.Redirect = "index.asp"
else
Response.Redirect = "<%strUrlName>"
end if %>

From the above code
Response.Redirect = "index.asp"
Response.Redirect = "<%strUrlName>"


are incorrect. it should be

Response.Redirect "index.asp"
Response.Redirect strUrlName


Response.Redirect is a function/method call not a variable assignment.
 
G

Griff

Actually, having just re-read it...

There are two methods for redirecting (one may be IIS specific, I don't
know).

One (if you can get it to work is better in my opinion) is to do a server
redirect. Here, the server redirects from one page to another without
having to go back to the client's browser with a lengthly round trip.

The second is the response redirect which goes back to the client's browser
and effectively says "you really don't want that page, you want this one..."
I've not tried this, but my guess is that the response redirect will
required a fully formed URL (http://www.yourdomain.org/page.asp)

hth

Griff
 
A

Aaron Bertrand [SQL Server MVP]

Shouldn't it be something like:
<%=strUrlName%>

No, did you try that?

<%
Response.Redirect "<%=strUrlName%>"
%>

Yields

Microsoft VBScript compilation error '800a0409'
Unterminated string constant

You're already inside an ASP block, why would you want to start another?
 
G

Griff

1. You mean SCRIPT, not PAGE.

Do I? ASP stands for Active Server Page. This is a PAGE that contains
SCRIPT. I can see one being transferred to a PAGE that contains SCRIPT, but
how can one be transferred to a SCRIPT that exists within a page? Even if I
am wrong, I believe PAGE was not a misunderstood term.
2. 302 responses are not lengthy.

It requires one extra round-trip which may well be perceived as slower by
the client if they are on a slow modem. Surely it's good practive to avoid
expensive network round-trips if at all possible?

3. A transfer is not a redirection.

Technically not, but often provides the same functionality if coded
properly.
Then perhaps you should have tried, or at least read up on it before
posting.

Ah, but whilst I didn't have the time to test it or read up on it before
posting it I knew that the incomplete answer I had should help point the
original poster in the correct direction to solving their problem.
Dave Anderson
Unsolicited commercial email will be read at a cost of $500 per message.
Use of this email address implies consent to these terms. Please do not
contact me directly or ask me to contact you directly for assistance. If
your question is worth asking, it's worth posting.

Now that paragraph really was worth reading!
 
T

Turkbear

Griff said:
Do I? ASP stands for Active Server Page. This is a PAGE that contains

[snip]

It's plural:

ASP stands for Active Server Pages. ASP is a server-side scripting language
that allows you to add interactivity to your Web sites.

-- http://webdesign.about.com/od/asp/

Sorry, ASP is not a scripting language( in spite of what that page says - that site seems to confuse things between
scripts and the program that can execute them) , see:
http://www.w3schools.com/asp/asp_intro.asp)
, it is a program that runs under IIS.
Scripts within ASP pages can use JavaScript or VBScript .
 
D

Dave Anderson

Griff said:
It requires one extra round-trip which may well be perceived
as slower by the client if they are on a slow modem. Surely
it's good practive to avoid expensive network round-trips if
at all possible?

302 responses are not expensive. They are very compact, in fact.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top