473,513 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

asp 404 error page question

I'm looking for a way to redirect based on when more than one condition is
met, I think I proably need some if/then statements? Can someone provide a
sample code or point me in the right direction...

Here's what I've got:

<%
Dim sScriptname, sRedirect
sScriptname = LCase(Request.ServerVariables("QUERY_STRING"))
response.write sScriptname
Select Case True
Case Instr(sScriptname, "392x72") > 0
sRedirect = "/392x72.htm"
Case Instr(sScriptname, ".htm") > 0
sRedirect = "/404.htm"
Case Instr(sScriptname, ".gif") > 0
sRedirect = "/blank.gif"
Case Instr(sScriptname, ".jpg") > 0
sRedirect = "/blank.jpg"
Case Instr(sScriptname, ".swf") > 0
sRedirect = "/blank.swf"
Case Else
sRedirect = "/ohcrap.htm"
End Select

Response.Redirect sRedirect
%>

What I'd really like to happen here is if "392x72" -and- ".gif" are found
then redirect to 392x72.gif and if "392x72" -and- ".htm" are found then
redirect to 392x72.htm Is this possible?

Thanks very much in adavnce, I'm new to this.
Jul 19 '05 #1
2 1524
Can't personally see anything wrong with what you have already, but you may
get a little better functionality if you change;

Instr(sScriptname, The_Ext) > 0

to

Instr(1, sScriptname, The_Ext, vbTextCompare) > 0
lord knows why, but, using it as you have, always seems to cause problems
for me, so started opting the for latter instead.
--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!
"JPElectron" <nope@i_dont_want_any_spam.com> wrote in message
news:c7**********@nntp2-cm.news.eni.net...
I'm looking for a way to redirect based on when more than one condition is
met, I think I proably need some if/then statements? Can someone provide a sample code or point me in the right direction...

Here's what I've got:

<%
Dim sScriptname, sRedirect
sScriptname = LCase(Request.ServerVariables("QUERY_STRING"))
response.write sScriptname
Select Case True
Case Instr(sScriptname, "392x72") > 0
sRedirect = "/392x72.htm"
Case Instr(sScriptname, ".htm") > 0
sRedirect = "/404.htm"
Case Instr(sScriptname, ".gif") > 0
sRedirect = "/blank.gif"
Case Instr(sScriptname, ".jpg") > 0
sRedirect = "/blank.jpg"
Case Instr(sScriptname, ".swf") > 0
sRedirect = "/blank.swf"
Case Else
sRedirect = "/ohcrap.htm"
End Select

Response.Redirect sRedirect
%>

What I'd really like to happen here is if "392x72" -and- ".gif" are found
then redirect to 392x72.gif and if "392x72" -and- ".htm" are found then
redirect to 392x72.htm Is this possible?

Thanks very much in adavnce, I'm new to this.

Jul 19 '05 #2
JPElectron wrote on 12 mei 2004 in
microsoft.public.inetserver.asp.general:
<%
Dim sScriptname, sRedirect
sScriptname = LCase(Request.ServerVariables("QUERY_STRING"))
response.write sScriptname
Select Case True
Case Instr(sScriptname, "392x72") > 0
sRedirect = "/392x72.htm"
Case Instr(sScriptname, ".htm") > 0
sRedirect = "/404.htm"
Case Instr(sScriptname, ".gif") > 0
sRedirect = "/blank.gif"
Case Instr(sScriptname, ".jpg") > 0
sRedirect = "/blank.jpg"
Case Instr(sScriptname, ".swf") > 0
sRedirect = "/blank.swf"
Case Else
sRedirect = "/ohcrap.htm"
End Select

Response.Redirect sRedirect
%>

What I'd really like to happen here is if "392x72" -and- ".gif" are
found then redirect to 392x72.gif and if "392x72" -and- ".htm" are
found then redirect to 392x72.htm Is this possible?


o Do not use case, unless you know very well what you are doing.
o Do not do a response.write before a redirect, it does not work.
o Else clauses after a redirect are not necessary.
Try:

<%
sSn = LCase(Request.ServerVariables("QUERY_STRING"))

If Instr(sSn,"392x72")>0 AND Instr(sSn,".gif")>0 Then
Response.Redirect "/392x72.gif"
End If

'' If Instr(sSn,"392x72")>0 AND Instr(sSn,".htm")>0 Then
'' Not needed, is taken care of by the next clause

If Instr(sSn,"392x72")>0 Then
Response.Redirect "/392x72.htm"
End If
If Instr(sSn,".htm")>0 Then
Response.Redirect "/404.htm"
End If
If Instr(sSn,".gif")>0 Then
Response.Redirect "/blank.gif"
End If
If Instr(sSn,".jpg")>0 Then
Response.Redirect "/blank.jpg"
End If
If Instr(sSn,".swf")>0 Then
Response.Redirect "/blank.swf"
End If

Response.Redirect "/ohcrap.htm"
%>


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #3

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

Similar topics

28
2323
by: Steve Bywaters | last post by:
There are several hundred of my client's franchisees happily accessing my ASP/VBscript web site... but one - just one - has reported the following: "I have been trying to log onto the LSM since...
7
3039
by: Paul | last post by:
I thought this is more of an IE issue but i've had no joy on that group perhaps somebody here will have a clue. If i click a link to a web page embedded in Excel (97 OR 2000) i get the standard...
1
1882
by: D A H | last post by:
I have gotten the same exception in multiple projects. I have solved the underlying problem. My question is if anyone knew of a setting that would cause this exception to be thrown. A...
25
17144
by: moondaddy | last post by:
I have an application where users need to upload images and in my web.config file I have a setting like this: <httpRuntime maxRequestLength="512" /> Which restricts image larger than 500k from...
6
4585
by: José Joye | last post by:
Hello, I'm currently reading the MS Developing Web applications with c# (and VB.net). In the chapter related to Error management, there is a sample about "Page-Level Error Pages" eg: In my...
13
2412
by: Max | last post by:
Hi There! I'm having a mysterious error right after I login using Forms Authentication in my ASP.NET app. Below is the error... Exception Details: System.NullReferenceException: Object...
10
3682
by: Rider | last post by:
Hi, simple(?) question about asp.net configuration.. I've installed ASP.NET 2.0 QuickStart Sample successfully. But, When I'm first start application the follow message shown. ========= Server...
1
2743
by: Alexander Higgins | last post by:
>>Thanks for the response.... Point Taken but this is not the case. Thus, if a person writes a text file on her or his computer and does not use UNICODE to save it, the current code page is...
15
16046
by: Dave | last post by:
I am getting the error above intermittantly with an ASP 3.0 page using an MS Access 2003 database. I have searched Google extensively and found the following possible causes for this error: A...
16
5031
by: john6630 | last post by:
Coming from the .Net world, I am used to the try...catch...finally approach to error handling. And PHP 5 now supports this approach. But I am not clear what happens to unhandled errors/exceptioins?...
0
7259
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
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7535
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...
1
7098
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
7523
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...
1
5085
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.