netラボ2012年3月勉強会ライトニングトーク
TRANSCRIPT
A look at ASP.NET MVC4 日本語解説
Twitter: david9142
Blog: テスターですが何か? http://david9142.wordpress.com/
A look at ASP.NET MVC4
2/19にオランダで行われた「TechDays 2012」
Scott Guthrieのセッション動画の日本語解説
動画はChannel9で公開 http://p.tl/rkxE
ASP.NET MVC4新機能
Bundling/Minification Support
Database Migration
Web APIs
Mobile Web
Real Time Communication
Asynchronous Support
Bundling/Minification Support(1)
今まではこう書いていた
<link href="styles/reset.css" rel="Stylesheet" />
<link href="styles/styles.css" rel="Stylesheet" />
<link href="styles/content.css" rel="Stylesheet" />
<link href="styles/glocals.css" rel="Stylesheet" />
<link href="styles/forms.css" rel="Stylesheet" />
<link href="styles/menu.css" rel="Stylesheet" />
これだと6回のHTTPリクエスト/レスポンスが発生する
Bundling/Minification Support(2)
こう書ける、ディレクトリ指定
<link href="styles/css" rel="Stylesheet" />
HTTP通信は1回のみ
改行、空白がカットされ通信料も削減
JavaScriptの場合はこう
<script src="scripts/js"></script>
Database Migration
Entiry Framework4.3よりCode FirstにDatabase Migration機能が追加
• Modelクラスの変更をデータベースへ反映可能
• ロールバックも可能
• モデル変更時の変更処理(C#/VB/SQL)を自動生成
• Enable-Migration, Add-Migration, Update-Databaseコマンド
Mobile Web
モバイル(PC以外のデバイス)向けのページを作成する機能
Adaptive Rendering • CSS Media Queryでウィンドウの大きさに応じてレイアウトが調整
Display Modes • デバイスに応じてViewをオーバーライ
Mobile Templates • jQueryMobileを使用したモバイルサイト用テンプレートを用意
Real Time Communication
双方向通信処理
ASP.NET 4.5でWebSocketをサポート
SignalRがGitHubで公開されている
(マルチユーザー向けのリアルタイムWeb作成用
ライブラリ)
Asynchronous Support
非同期処理(ASP.NETだけではなく、.NET4.5の新機能)
async/awaitキーワードを使用して以下のように記述できる
public class Products : Controller
{
public async Task<ActionResult> IndexAsync()
{
webClient web = new WebClient();
string result = await web.DownloadStringAsync("www.bing.com");
return View();
}
}