Solved

If Recordset Null Response 404

Posted on 2012-03-15
5
402 Views
Last Modified: 2012-03-26
Hello,

I have a page that returns results from a recordset..

I want the page to respond with 404 when no records are returned.

I've tried this ---

<% If ISNULL(descript) Then %>
<%
   Response.Status = "404 Not Found"
%>
<%End if%>

But this is doing nothing??

I do have a web.config file with --

<httpErrors  errorMode="DetailedLocalOnly">
     <remove statusCode='500' subStatusCode='100'/>  
     <error statusCode='500' subStatusCode='100' prefixLanguageFilePath='' path='/error/500.asp' responseMode='ExecuteURL'/>  
     <remove statusCode='404' subStatusCode='-1'/>  
     <error statusCode='404' subStatusCode='-1' prefixLanguageFilePath='' path='/error/404.asp' responseMode='ExecuteURL'/>  
</httpErrors>      

So once the 404 is returned, the site should send the user to the custom 404 page...

Clearly I'm doing something wrong, please advise.

Many thanks
0
Comment
Question by:garethtnash
5 Comments
 
LVL 16

Expert Comment

by:brad2575
ID: 37726352
Could you just not do a redirect to your 404 page?

Response.Redirect(URL)
?
0
 
LVL 13

Assisted Solution

by:devlab2012
devlab2012 earned 250 total points
ID: 37732562
You have posted your question under "Active Server Pages". But in your question, you have also mentioned web.config.
In Active Server Pages, there is no web.config. Web.config is used in ASP.NET applications.

Anyway, In your code, replace the line:

   Response.Status = "404 Not Found"

with the following three lines:

Response.clear
Response.Status = "404 File Not Found"
Response.End
0
 
LVL 13

Expert Comment

by:devlab2012
ID: 37732566
Also, note that for the above code to work, the buffering must be on for the page.
0
 
LVL 32

Accepted Solution

by:
Big Monty earned 250 total points
ID: 37738241
i would change

<% If ISNULL(descript) Then %>

to

<% If ISNULL(descript) or if decript = "" Then %>

this is assuming descript is a string variable, if you want to check the actual recordset, you would do

<% If rs.BOF and rs.EOF Then %>
0
 

Author Closing Comment

by:garethtnash
ID: 37764670
Thanks All
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now