1 / 13

virtual techdays

INDIA │ 9 th – 11 th January 2011. virtual techdays. ASP.Net MVC. Sundararajan S │ Associate Tech Architect, Aditi Technologies. INDIA │ 9 th – 11 th January 2011. virtual techdays. MVC ASP.Net MVC Hybrid Projects in Asp.Net MVC. S E S S I O N A G E N D A.

mulan
Download Presentation

virtual techdays

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. INDIA │ 9th – 11th January 2011 virtual techdays ASP.Net MVC Sundararajan S │ Associate Tech Architect, Aditi Technologies

  2. INDIA │ 9th – 11th January 2011 virtual techdays • MVC • ASP.Net MVC • Hybrid Projects in Asp.Net MVC S E S S I O N A G E N D A

  3. MVC Design pattern • Conery, Hanselman, Haack, Guthrie define it as… • An architectural pattern used to separate an application into three main aspects • Model. Set of classes that represent data and business rules for how data can be changed and manipulated • View.Application’s user interface • Controller. Set of classes that handles communication from user, overall application flow, and application-specific logic

  4. Web forms issues • Web forms don’t support as precise control over “separation of concerns” • Too much of an application ends up in the “code behind” • High level of abstraction • Not as “close to the metal” as some devs want • Web forms are not as well suited for testing • Testing the “code behind” code is difficult • Search engine optimization (SEO) issues • ASP.NET 4.0 addresses this

  5. Model View Controller • Model - Data and Business Rules • View – Presentation layer – Aspx / HTML • Controller – Classes that are responsible for application flow

  6. INDIA │ 9-11 Januarty 2011 virtual techdays Demo – Building a Blog engine in Asp.Net MVC Sundararajan S│ Assoc. Tech Architect, Aditi

  7. ASP.Net MVC Request Processing Architecture Incoming HTTP Request Routing IIS / ASP.Net Matching file on disk Serve the file directly URL Routing Module RouteTable.Routes IRouteHandler IHttpHandler MVCRouteHandler Controller/ Actions Custom controller factory IController ControllerFactory Writes directly to http response ActionMethod Not A ViewResult? Return ActionResult ActionResult.Execute Is A ViewResult?

  8. ASP.Net MVC Request Processing Architecture Views View Engine Custom View Engine WebForm - .Aspx Render View

  9. Hybrid Projects • Add ref to System.Web.Mvc.dll - need to browse for it under C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies • Add ref to System.Web.Routing • Create an Empty MVC Project • Copy the Controllers, Models and Views directories into the Web Forms application • Copy the RegisterRoutes method in Global.asax to the Global.asax in the Web Forms project • Add RegisterRoutes(RouteTable.Routes); to the Application_Start in the Web Forms project • Add using System.Web.MVC and using System.Web.Routing to Global.asax in the Web Forms project

  10. Hybrid projects • Add the following to the <compilation> section of web.config <assemblies> <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> </assemblies>

  11. Add the following to the <pages> section of web.config <namespaces> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> </namespaces>>

  12. Enable MVC Tooling in Web Form Application • Right-click on project and select unload • Right-click on project and select Edit .csproj • In <ProjectTypeGuids> section add at beginning of list of Guids: {F85E285D-A4E0-4152-9332-AB1D724D3325} • Right-click on project and select reload • Close and reopen solution

  13. Thank you sundararajans@hotmail.com http://tinyurl.com/codeshelve

More Related