Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

If Recordset Null Response 404

Posted on 2012-03-15
5
413 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 33

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
JS does not refresh 6 30
remove computer from using logon script 17 38
need the count of duplicate records in a column 12 43
checkbox to hide entire section 10 41
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

856 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