ASP.NET MVC Action Filters

來源:互聯網
上載者:User

在看這篇Fun with Http Headers in ASP.NET MVC Action Filters的時候,提到了 Roni Schuetz在codeplex上建立的一個項目ASP.NET MVC Action Filters。計劃在5月10日推出第一個版本。 專案計劃包含的Action Filter:

  • Action filter for creating easy REST API with JSON and XML
  • Action filter for logging scenarios
  • Action filter for microsoft health monitoring
  • Action filter for client caching
  • Action filter for client compression
  • Action filter for server caching
  • Action filter for controller execution time measurement

簡要介紹一下Action Filter:Action Filter作為一個可以應用到Controller Action(或者是整個controller)上的屬性(Attribute),改變Action執行的行為。ASP.NET MVC Framework包括幾種Action Filter:

  • OutputCache – 在指定的時間內緩衝Controller Action的輸出。
  • HandleError – 處理Controller Action發生錯誤的情況。
  • Authorize – 通過制定的使用者或者角色約束存取權限。

你同時可以建立自己的Action Filter,比如說要實現一個自訂的驗證系統,那麼可能需要建立一個自訂的Action Filter,或者說當你需要改變Controller Action返回的View data的時候,也可以通過建立自訂Action Filter實現。

關於Action Filter的具體內容可參考 理解ASP.NET MVC Framework Action Filters(翻的)。

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.