Link to home
Start Free TrialLog in
Avatar of garethtnash
garethtnashFlag for United Kingdom of Great Britain and Northern Ireland

asked on

If Recordset Null Response 404

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
Avatar of brad2575
brad2575
Flag of United States of America image

Could you just not do a redirect to your 404 page?

Response.Redirect(URL)
?
SOLUTION
Avatar of devlab2012
devlab2012
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also, note that for the above code to work, the buffering must be on for the page.
ASKER CERTIFIED SOLUTION
Avatar of Big Monty
Big Monty
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of garethtnash

ASKER

Thanks All