Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 13th, 2007, 08:15 PM
Registered User
 
Join Date: Nov 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I fake a 404?

I have an .aspx page in which I want to restrict access to only one remote server. On this page I check for the correct Request.UserHostAddress.

Now if it isn't that IP address, how do transfer the request to the default 404 page? I haven't created a 404 page, nor do I want one. I just want it to look as if that page (actually the whole directory) doesn't exist to anyone besides my remote machine... In otherwords, I want the same thing to happen if they were to randomly type jibberish to my domain (Ex: http://sometest.websitethat.com/does...hhtrey33g.aspx)

 
Old November 13th, 2007, 09:02 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

Something like this will work:

if(Request.UserHostAddress != <foo>)
{
   Response.StatusCode = 404;
   Response.End();
}

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========





Similar Threads
Thread Thread Starter Forum Replies Last Post
Status 404 for 404 page marun BOOK: Professional Apache Tomcat 0 August 30th, 2005 06:45 AM
404 error scrowler Pro PHP 1 December 19th, 2004 11:36 AM
replacing querystrings with fake page names mase912 C# 0 November 24th, 2004 04:47 AM
Fake Response Object dotCOMer Pro VB 6 1 October 23rd, 2003 06:09 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.