From the course: ASP.NET MVC: HTTP Request Life Cycle

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Implement a custom HTTP handler

Implement a custom HTTP handler

From the course: ASP.NET MVC: HTTP Request Life Cycle

Start my 1-month free trial

Implement a custom HTTP handler

- [Instructor] Let's create a custom HTTP handler that'll process requests in a synchronous manner. First, we'll add a new class library project to our solution. Then we'll name it CustomHttpHandler. Go ahead and delete the default class. We'll add a new item to the project. Go ahead and pick the Web category and add an ASP.NET Handler. Let's name it RssHandler. It'll respond to a request with simple XML to mimic an RSS feed. Notice how the handler has to implement the IHttpHandler interface. This has two members we have to define. The IsReusable property specifies whether the handler can be put in a pool to be reused. We'll set it to false, so that we can create a new instance of the handler for each request. The process request method does the actual processing of the request. This is what ASP.NET calls when a handler is requested and it creates the response to send back to the browser. In our example, we'll be returning a mock RSS feed. We can use the context object to access the…

Contents