How to override response "403-Forbidden" with "404-File not found" using ProcessRequest

Posted on 2012-09-21
Last Modified: 2013-06-25
Working on one of the application. Whenever the user type any folder name like "css" or "scripts" it should throwing a "403-Forbidden" error which means there is a possibility for security vulnerabilities. Instead the response should throw an "404-File not found".

Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest

        Dim url As String = context.Request.Url.ToString
        If (url.ToLower().Contains("css")) Then
            context.Response.Status = "404 File Not Found"
            context.Response.AddHeader("Location", url)
        End If
    End Sub

<add verb="*" path="??????" type="MyHttpHandler.MyHttpHandler"></add>

Please suggest me. What i need to specify in the path??
Question by:srepolavarapu
    1 Comment
    LVL 19

    Accepted Solution

    You can do this by modifying your web.config code.  To save my fingers,

    gives a complete run down of how to do this:)

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Suggested Solutions

    Recently while returning home from work my wife (another .NET developer) was murmuring something. On further poking she said that she has been assigned a task where she has to serialize and deserialize objects and she is afraid of serialization. Wha…
    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

    779 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

    15 Experts available now in Live!

    Get 1:1 Help Now