ASP.NET Interview question :- What are HttpHandler and HttpModules and how do they differ?

 Posted by articlesmaint on 2/24/2011 | Category: .NET Framework Interview questions | Views: 50006


Both the above concepts are rarely used by developers but mostly asked in .NET interviews ;-).

The prime  and common goal of HttpHandler and httpModule is to inject pre-processing logic before the ASP.NET request reaches the IIS server.


HttpHandler is a extension based processor in other words pre-processing logic is executed depending on file extensions. For instance sometimes you would like to check that a person should be above age of 18 if he is trying to view any  files with extension *.MP4.


HttpModule is event based processor. ASP.NET engine emits out lot of events as the request traverses over the request pipeline. Just to name some events beginrequest,authorizerequest,authenticaterequest etc. By using HttpModule you can write logic in these events. These logic get executed  as the events fire and before the request reaches IIS server.


So a short answer for the above .NET interview question would be HttpHandler is a extension based processor while HttpModule is a event base processor. Both of them help to inject pre-processing logic before the ASP.NET request reaches the IIS server.




Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response