MS IIS 7.5 - HTTP Message Error code customization

Posted on 2011-05-02
Last Modified: 2012-05-11
In my filter inside of IIS7.5 for some conditions I am deciding to send blocking message.
Generally I am using HTTP code 200.
But sometime there is a need to send another one.
When another one is chosen and it is not in the range 400-500 everything is ok and message is going out of IIS with this HTTP code and relevant content I put.

But if I choose for example HTTP code 403 - IIS intercepting it, putting HTTP code 200 and embed the code I custom to 403 inside of HTML body.

Can somebody advice on this?
Question by:longjumps
    LVL 1

    Author Comment

    Attached is the example of what happen with response message that was send to browser from IIS 7 when I am trying to send block message from one of filters with HTTP code 403.
    However other code, e.g. 205 no problem!
    LVL 1

    Author Comment

    I did more test on this issue so once I browse some site from local browser or curl tool I am getting correct message for block with content I am expecting.
    However once I browse for same site that from my IIS module I am sending blocking message with Error Code IIS takes "ownership" and send his 403 message instead of mine that was customise in my IIS module.

    This happens only in IIS7, with error codes  4xx and 5xx, other codes I succeeded override and IIS7 is not overriding them again.

    Can somebody help on this?

    LVL 1

    Accepted Solution

    LVL 1

    Author Closing Comment

    I found solution by myself and spent time on that.

    Now I am sharing this advanced topic with others.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
    With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

    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

    12 Experts available now in Live!

    Get 1:1 Help Now