ASP.NET/C#:  Exit from CustomHttpModule

Posted on 2013-10-07
Medium Priority
Last Modified: 2013-11-08
Using ASP.NET/C# I have a custom CustomHttpModule, referenced in web.config like this:
<add name="CustomHttpModule" type="org.HeaderHack.CustomHeaderModule" />

Open in new window

If certain criteria are met, I want to send a 404 header and exit.

I send the 404 header like this:
HttpContext.Current.Response.StatusCode = 404;

Open in new window

The problem is that the application continues after the 404 header is sent.

How can I exit the application from the CustomHttpModule?
Question by:hankknight
1 Comment

Accepted Solution

Pavel_Kudishin earned 2000 total points
ID: 39619735
Use HttpApplication.CompleteRequest Method in your Http module to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event.

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…

624 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