ASP.NET Interview Questions on HTTP modules and HTTP Handlers



What is an HTTP Handler?

An ASP.NET HTTP handler is the process (frequently referred to as the "endpoint") that runs in response to a request made to an ASP.NET Web application. The most common handler is an ASP.NET page handler that processes .aspx files. When users request an .aspx file, the request is processed by the page through the page handler. You can create your own HTTP handlers that render custom output to the browser.

What is HTTP module?An HTTP module is an assembly that is called on every request that is made to your application. HTTP modules are called as part of the ASP.NET request pipeline and have access to life-cycle events throughout the request. HTTP modules let you examine incoming and outgoing requests and take action based on the request.

What is the interface that you have to implement if you have to create a Custom HTTP Handler?
Implement IHttpHandler interface to create a synchronous handler.
Implement IHttpAsyncHandler to create an asynchronous handler.

What is the difference between asynchronous and synchronous HTTP Handlers?A synchronous handler does not return until it finishes processing the HTTP request for which it is called.

An asynchronous handler runs a process independently of sending a response to the user. Asynchronous handlers are useful when you must start an application process that might be lengthy and the user does not have to wait until it finishes before receiving a response from the server.

Which class is responsible for receiving and forwarding a request to the appropriate HTTP handler?
IHttpHandlerFactory Class

Can you create your own custom HTTP handler factory class?
Yes, we can create a custom HTTP handler factory class by creating a class that implements the IHttpHandlerFactory interface.

What is the use of HTTP modules?
HTTP modules are used to implement various application features, such as forms authentication, caching, session state, and client script services.

What is the difference between HTTP modules and HTTP handlers?An HTTP handler returns a response to a request that is identified by a file name extension or family of file name extensions. In contrast, an HTTP module is invoked for all requests and responses. It subscribes to event notifications in the request pipeline and lets you run code in registered event handlers. The tasks that a module is used for are general to an application and to all requests for resources in the application.

What is the common way to register an HTTP module?The common way to register an HTTP module is to have an entry in the application's Web.config file.

Much of the functionality of a module can be implemented in a global.asax file. When do you create an HTTP module over using Global.asax File?
You create an HTTP module over using Global.asax file if the following conditions are true

1. You want to re-use the module in other applications.
2. You want to avoid putting complex code in the Global.asax file.
3. The module applies to all requests in the pipeline.

9 comments:

  1. For ASP.Net interviews this blog is the best.
    Jay

    ReplyDelete
  2. Am loving it ...... the best interview blog i have ever see... Neatly arranged.... Thank you very much for putting all the information at a place... Am really grateful to you....

    ReplyDelete
  3. These are just giving basic information, may be it needs to have more deeper questions,like, if interviewer ask about, what are the events we can subscribe to an httpmodule...(this is a frequest question) and so on...

    ReplyDelete
  4. Amazing blog every came accross for interview questions and answers

    ReplyDelete
  5. superb job......excellent ...keep up the good work..This is an wonderful knowledge giving site..i am sure after reading all these interview Q and A..It gives 100% confidence to attend the interview..I am very grateful to u.God bless for your success.

    ReplyDelete
  6. hey no doubt ur explanation is excellent.... Explain with one example how to create custom handlers and how to implement httpmodules in global.asax .....

    ReplyDelete
  7. Really it is super powerful site...with good explanation

    ReplyDelete
  8. venkat do u have video on http modules and helpers?

    ReplyDelete

If you are aware of any other asp.net questions asked in an interview, please post them below. If you find anything missing or wrong, please feel free to correct by submitting the form below.

 
Disclaimer - Terms of use - Contact Us