Over view and Controllers

Please download to get full document.

View again

of 32
All materials on our website are shared by users. If you have any questions about copyright issues, please report us to resolve them. We are always happy to assist you.
Information Report



Views: 3 | Pages: 32

Extension: PDF | Download: 0

Related documents
MSP Tech Club Session five talking about mvc and how mvc works; An Intro to The letter C in mvc Which is Controller.
  • 1. AW Prepared and presented by : Muhammad Hesham & Mustafa Saeed Aspiration Webbers Session 5 (Asp.Net) Controller
  • 2. •Reko Meets ASP.NET •What is ASP.NET •Architecture of MVC •Controller Objectives
  • 3. ASP.NET Overview
  • 4. What is MVC The MVC design pattern decouples the major components of an application allowing for efficient code reuse and parallel development.
  • 5. Model,View,Controller Controller View Model
  • 6. Every web application needs some structure MVC helps you to stay organized Often end up with less code, not more Smoother learning curve as your project growsmplicated, What’s the point? Seems complicated, What's the point?
  • 7. Unit testing helps you change code with confidence ASP.NET MVC is designed to make unit test easy Testability
  • 8. A controller is just a class No really it is just a class :D Controller
  • 9. public class AlbumController : Controller { } public ActionResult Create() { } Controller
  • 10. public class AlbumController : Controller { public ActionResult Create() { } } Controller
  • 11. ActionResult ActionResult ContentResult JavascriptResult JsonResult RedirectResult ViewResult
  • 12. ActionResult Name Framework behivor Method Name ContentResult Returns a string literal Content JavaScriptResult Returns a script to execute Javascript JSONResult Returns data in json json RedirectResult Redirects the client to a new URL Redirect ViewResult Response is the responsibility of a view View / ParialView
  • 13. //Test/ReturnContent public ContentResult ReturnContent() { return Content("Hello Heros"); } ContentResult
  • 14. //Test/ReturnContent public ActionResult ReturnContent() { return Content("Hello Heros"); } ContentResult
  • 15. // Test/ReturnJson public ActionResult ReturnJson() { return Json( new { name = "Reko", LastName = "MSP" }, JsonRequestBehavior.AllowGet); } JsonResult
  • 16. //Test/ReturnNot public ActionResult ReturnNot() { return HttpNotFound("Sorry !!!"); } HTTP Code
  • 17. //Test/ReturnHttpCode public ActionResult ReturnHttpCode() { return new HttpStatusCodeResult(500); } HTTP Code
  • 18. // Test/ReturnFile public ActionResult ReturnFile() { return File(Server.MapPath( "~/Content/Site.css"), "text/css"); } Return a File
  • 19. string Int Person Or anything !! Actions parameters
  • 20. // Test/Search?name=Something public ActionResult Search(string name) { return Content(name); } Actions parameters
  • 21. Actions attributes Action VerbAction Selector
  • 22. [ActionName("Modify")] public ActionResult Edit() { return Content("Modify Action"); } Actions Selector //Test/Modify
  • 23. Actions Verbs Get data form the server. Post data to the server. Update data on the server. Delete data from the server. [HttpPost] [HttpGet] [HttpPut] [HttpDelete]
  • 24. [OutputCache] [Authorize] Actions Filters
  • 25. Routes C M V routes.MapRoute( name: "Default", url: "{controller}/{action}/{name}", defaults: new { controller = "Home", action = "Index", name = UrlParameter.Optional });
  • 26. public ActionResult Search(string name) { return Content(name); } Routes
  • 27. Demo
  • 28. Contact :
  • We Need Your Support
    Thank you for visiting our website and your interest in our free products and services. We are nonprofit website to share and download documents. To the running of this website, we need your help to support us.

    Thanks to everyone for your continued support.

    No, Thanks

    We need your sign to support Project to invent "SMART AND CONTROLLABLE REFLECTIVE BALLOONS" to cover the Sun and Save Our Earth.

    More details...

    Sign Now!

    We are very appreciated for your Prompt Action!