HTTP Modules versus ASP. NET MVC Action Filters

Source: Internet
Author: User

From:http://odetocode.com/blogs/scott/archive/2011/01/17/http-modules-versus-asp-net-mvc-action-filters.aspx

Monday, January 17, 2011

The ASP. NET MVC has the action filters, while the ASP. HTTP modules. Inside their respective processing pipelines, these abstractions serve similar purposes, and I ' ve heard the following ques tion a few times:

When should I write a HTTP module and when should I write an action filter?

If You is creating an MVC application then I'll almost  always  recommend going with an action filter Instead of an HTTP module. This is my recommendation even if the functionality your is creating is generic enough to work from inside a module (in OT Her words, it doesn ' t depend in MVC specific pipeline stages, like the pre and post processing of action invocation). Filters is closely aligned with the MVC infrastructure and vocabulary, and Filters is the first thing someone would look For if they want to see how you ' ve implemented cross-cutting functionality in MVC.

On the other hand, a HTTP module is something you can reuse in any type of ASP. Witness the flexibility of Elmah-just drop an assembly in the bin directory, tweak a config file, and wait for Elmah to Record errors across an entire application. This configurable flexibility isn ' t something you can does with filters out of the box, but we'll see tomorrow how easy it I s to add.

HTTP Modules versus ASP. NET MVC Action Filters

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.