packages 3-31 PART 3-31 03-03 ASP.NET ASP.N MVC ASP.NET ASP.N MVC 4 ASP.NET ASP.NE MVC Entity Entity Framework Code First 2 TIPS Visual Studio 20NuGetEntity NuGetEntity Framework5.0 CHAPTER 03 59
3-3-1 4 Visual Studio 222 3-32 Web 4 Web MvcGuestbook MvcGuestbook 3-33 4 Web 60 4
PART TIPS Visual Studio 22 2 1.0 2.0Visual Studio 20 ASP.NET 3 Application Upgrader 3 Application plication Upgrader 2.0 3.0 4.0 3 Application plication Upgrader http://aspnet.codeplex.com/releases/view/59008plex.com/releases/v 3 Application plication Upgrader http://blogs.msdn.com/b/marcinon/archive/21//13/mvc-3-project-upgrade- archive/21//13/mvc-3-project-upgrade-3-project-upgrade- tool.aspx 3-34 3-34 4 CHAPTER 03 61
( F5) 4 3-35 33 (Layout Page)ASP.NETMembership 3-36ASP.NET P MVC 4 62 4
4 App_Data (*.mdf, *.ldf) aspnet--.mdf3-37 PART 3-37 4 TIPS Visual Vis Studio 22App_ App_ Data 4 3-38 CHAPTER 03 63
CSS/JS Action Filter (Routing) CSS Models EDMXDBML EDMXDBML JavaScriptVBScript HomeController LayoutPartial View 3-38 TIPS 2 ASP.NET Web Forms ASP.NET ASP.NET Web FormsASP.NET MVC 64 4
PART ASP.NET Web /Index.aspx http://localhost/ Forms /Index.aspx.cs http://localhost/ /Controller/HomeController.cs /Views/Home/Index.aspx ASP.NET Web http://localhost/ /About.aspx () Forms About.aspx /About.aspx.cs () http://localhost/ /Controller/HomeController.cs () Home/About /Views/Home/About.aspx () 3-1ASP.NET Web Forms ASP.NET Web Forms ASP.NET MVC ASP.NET ASP.NE MVC (Routing)App_Start\ RouteCong.csRegisterRoutes RegisterR es public static void RegisterRoutes(RouteCollection s(routecollection routes) routes.ignoreroute("resource.axd/*pathinfo"); e.axd/*pathinfo routes.maproute( name: "Default", url: "controller/action/id", on/id", defaults: new controller = "Home", action = "Index", id = UrlParameter.Optional ); (Routing) IgnoreRoute *.axd ASP.NET ASP.NETTrace.axdHttpHandlerASP. HttpHan NET MVCASP.NET Web Form CHAPTER 03 65
MapRoute MapRouteASP.NET 1. name 2. url 3. defaults controlleractionid 3 MapRoute http://localhost/home/about Routing Home/About controller Home action About ControllersHome (HomeController.cs) About (Public Method)MVC (Action) http://localhost/routing Routing MapRoute3 (defaults) ControllersHome Controllers IndexASP.NET TIPS Routing controller action ASP.NETT MVCController Controller Actiondefaults defaultsd HomeController using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; 66 4
PART namespace MvcGuestbook.Controllers public class HomeController : Controller public ActionResult Index() ViewBag.Message = " "; return View(); public ActionResult About() ViewBag.Message = ""; return View(); public ActionResult Contact() ViewBag.Message = ""; "; return View(); (Controller) ControllerGuestbookControllerGuestbook GuestbookContr erguestbook Controller (IController) ActionResultASP.NET ASP MVC (Action) IndexViewBagdynamic ASP.NET MVC View ViewBag.Message = " "; CHAPTER 03 67
TIPS (dynamic) C# 4.0ASP.NET 4.0.NET Framework 4.0 return View(); Controller (Helper Method)ViewResultViewResultActionResultViewResult (View) HomeIndex View()ASP.NET ASP.N MVCViews\Home\ Views\Home\ Index.aspx Visual l Studio 3-39 @ @ 3Razor ()ASP.NET MVC 2.0ASP.NET Web FormASPXRazor View 4ASP.NET MVCWebForm ViewRazorViewRazor View 68 4
PART 3-40 (Action) (View) Index.cshtmlHTMLInd HTM ASP.NET Web Form 2.0MasterPage 4.0 Views _ViewStart.cshtml View View View (Layout Page) _ViewStart.cshtml 3Layout ~/Views/Shared/_Layout. cshtmlviews s (View) 3-41Views\ Views\ _ViewStart.cshtml t.cshtml 3-42Views\_ViewStart.cshtml CHAPTER 03 69
~/Views/Shared/_Layout.cshtml HTML3-43 3-43Views\Shared\_Layout.cshtml ControllerViewBag.MessageIndex. rviewbag essage cshtml (View) @ViewBag.Message Index.cshtmlViewBag.Title ViewBag.Title View_Layout.cshtml _Layout.cshtml 3-44Views\Home\Index.cshtml 70 4
PART 3-45Views\Shared\_Layout.cshtml 3-3-2 StepModels 3-46 CHAPTER 03 71
Step Guestbook.cs 3-47 Step03 namespace MvcGuestbook.Modelsok.Models public class Guestbook public int Id get; set; public string get; set; public string Email get; set; public string get; set; Step 3-48 72 4
PART TIPS (Model) ADO.NET,, LINQ to SQL, NHibernateEntity FrameworkModels Models Models 3-3-3 StepControllers 3-49Controllers CHAPTER 03 73