ASP.NET MVC 4 Beta 新功能特性:
(1) ASP.NET Web API
(2) 添加移動項目模板
(3) 對移動 app 特性的功能支援,JQuery Moblie,View Switcher and Browser Overriding
(4) 提升自訂代碼產生器
(5) 增強非同步方法呼叫,非同步產生器提供返回參數支援 Task 執行個體。
(6) 單頁面應用程式的支援
(7) 增強預設範本功能。
(8) 更好的支援 Windows Azure SDK
(9) 改進 Razor View Engine.
(10) 當 WebMatrix.WebData.dll 被放在項目目錄中/bin 中時,將請求 URL 時候預設 froms 身份認證。
在 ASP.NET Web API 中共有以下幾個特性:
Modern HTTP programming model:
最強大的功能之一, 它可以在 HttpWebRequest 中公開強行別的資料
Full support for routes:
它也是 Route 基礎下,因此支援 MVC 所有功能,如 [HttpPost] 等 Attributes 。
Content negotiation:
它的 Client 與 Server 使用共同的 API 與資料格式,預設支援 JSON、XML 等。當然您也可以在這個基礎上開發自己的資料轉送格式。
Model binding and validation:
在模型繫結中使用強行別 HttpWebRequest 的資料,使用上更容易。
Filters: 如同 MVC 準系統一樣,支援動作、驗證的過濾等動作,以及錯誤處理的部分。
Query composition:
它可公開如 IQueryable<T> 可查詢的介面。也支援 OData 協議。
Improved testability of HTTP details:
在這個平台上,HTTP的行細資訊、Context 對象等動作,現在多了HttpRequestMessage 與 HttpResponseMessage 這兩個執行個體對象。就是透過它使您可以在 HttpWebRequest 中傳遞自定的型別。
Improved Inversion of Control (IoC) via DependencyResolver:
如同 MVC 的架構上,你很容易實現 IoC 的設計模式。
Code-based configuration:
設定 Web API 的相關功能只要使用幾行 Code 就可以了,不需要修改任何 Configuration 檔案的內容。
Self-host: 前面有提到過了,Web API 的服務的部分是允許獨立出來進行服務的。稱為 Self-Host。
更多資源:請參考http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253813
asp.net mvc web api 教程
:http://www.asp.net/mvc/mvc4
http://weblogs.asp.net/jgalloway/archive/2012/02/16/asp-net-4-beta-released.aspx
Getting Started with ASP.NET Web API
http://www.asp.net/web-api
Introducing ASP.NET MVC 4 Beta with Web APIs
http://blogs.msdn.com/b/carlosfigueira/archive/2012/02/16/introducing-asp-net-mvc-4-beta-with-web-apis.aspx
Bundling and Minification in ASP.NET MVC 4
http://www.dotnetexpertguide.com/2011/12/bundling-and-minification-aspnet-mvc4.html
Self-Host a Web API (C#)
http://www.asp.net/web-api/overview/hosting-aspnet-web-api/self-host-a-web-api