Jim Fawcett CSE686 – Internet Programming Summer 2010

Slides:



Advertisements
Similar presentations
INTRODUCTION TO ASP.NET MVC AND EXAMPLE WALKTHROUGH RAJAT ARYA EFECS - OIM DAWG – 4/21/2009 ASP.NET MVC.
Advertisements

Introduction to MVC Adding a View Page NTPCUG Tom Perkins, Ph.D.
1.  Understanding about How to Working with Server Side Scripting using PHP Framework (CodeIgniter) 2.
Razor. Slide 2 Remember this? Browser Web Server HTTP Request HTTP Response (Web page / code) Client code (script) Interpret request Generate HTML and.
Multiple Tiers in Action
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
JQuery CS 268. What is jQuery? From their web site:
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Introduction to MVC Adding Model Classes NTPCUG Tom Perkins, Ph.D.
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
.Net is a collection of libraries, templates and services designed to make programming applications of all kinds, easier, more flexible (multi platform),
Overview of Previous Lesson(s) Over View  ASP.NET Pages  Modular in nature and divided into the core sections  Page directives  Code Section  Page.
ASP.NET  ASP.NET is a web development platform, which provides a programming model, a comprehensive software infrastructure and various services required.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
Introduction to ASP.NET MVC Information for this presentation was taken from Pluralsight Building Applications with ASP.NET MVC 4.
Introduction to Entity Framework Part 2 CRUD Scaffolding Tom Perkins NTPCUG.
Lap Around Visual Studio 2008 &.NET 3.5 Enhancements.
Caching Chapter 12. Caching For high-performance apps Caching: storing frequently-used items in memory –Accessed more quickly Cached Web Form bypasses:
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Christopher M. Pascucci Basic Structural Concepts of.NET Managing State & Scope.
Introduction to MVC Controllers NTPCUG Tom Perkins, Ph.D.
 Registry itself is easy and straightforward in implementation  The objects of registry are actually complicated to store and manage  Objects of Registry.
Getting started with ASP.NET MVC Dhananjay
AJAX and REST. Slide 2 What is AJAX? It’s an acronym for Asynchronous JavaScript and XML Although requests need not be asynchronous It’s not really a.
Introduction  “M” “V” “C” stands for “MODEL” “VIEW” “CONTROLLER”. ASP.NET MVC is an architecture to develop ASP.NET web applications in a different manner.
ASP.NET MVC An Introduction. What is MVC The Model-View-Controller (MVC) is an architectural pattern separates an application into three main components:
Text INTRODUCTION TO ASP.NET. InterComm Campaign Guidelines CONFIDENTIAL Simply Server side language Simplified page development model Modular, well-factored,
Submitted by: Moran Mishan. Instructed by: Osnat (Ossi) Mokryn, Dr.
BIT 286: Web Applications Lecture 04 : Thursday, January 15, 2015 ASP.Net MVC -
Generating XML Data from a Database Eugenia Fernandez IUPUI.
MVC Controllers TestsMigrations Ye Olde Internet Model DB Server Router View Browser Today’s focus Controller.
Jim Fawcett CSE686 – Internet Programming Spring 2014
Introduction to Silverlight
Computing with C# and the .NET Framework
Asp.Net MVC Conventions
An introduction to ASP.Net with MVC Nischal S
Unit 9.1 Learning Objectives Data Access in Code
Jim Fawcett CSE686 – Internet Programming Spring 2012
Displaying XML Data with XSLT
Using ASP.NET Master Pages
Security Basics and ASP.NET Support
ASP MVP Web applications and Razor
C#: ASP.NET MVC Overview
Play Framework: Introduction
AJAX and REST.
Haritha Dasari Josue Balandrano Coronel -
Introduction to Silverlight
CO6025 Advanced Programming
PHP / MySQL Introduction
Jim Fawcett CSE686 – Internet Programming Summer 2008
Prepared for Md. Zakir Hossain Lecturer, CSE, DUET Prepared by Miton Chandra Datta
Introduction to Internet Programming
04 | Web Applications Gerry O’Brien | Technical Content Development Manager Paul Pardi | Senior Content Publishing Manager.
State management & Master Pages in asp.net
jQuery The Easy JavaScript Nikolay Chochev Technical Trainer
Accessing Data in a .NET Web Application
Lecture Set 14 B new Introduction to Databases - Database Processing: The Connected Model (Using DataReaders)
Static and Dynamic Web Pages
CIS 133 mashup Javascript, jQuery and XML
MVC Controllers.
MVC Controllers.
MVC Controllers.
Ajax and JSON Jeremy Shafer Department of MIS Fox School of Business
Asp.Net MVC Conventions
Chengyu Sun California State University, Los Angeles
Model View Controller (MVC)
Presentation transcript:

Jim Fawcett CSE686 – Internet Programming Summer 2010 Asp.Net mvc

What is Asp.Net MVC? Framework for building web applications Based on Model-View-Controller pattern Model manages the applications data and enforces constraints on that model. Often accessed through persistent objects Views are mostly passive presentations of application state. Views generate requests sent to a controller based on client actions. Controllers translate requests into actions on the data model and generate subsequent views.

MVC Life Cycle Clients request a named action on a specified controller, e.g.: http://localhost/aController/anAction The request is routed to aController’s anAction method. That method decides how to handle the request, perhaps by accessing a model’s state and returning some information in a view.

What is a Model? A model is a file of C# code and an associated data store, e.g., an SQL database or XML file. The file of C# code manages all access to the application’s data through objects. Linq to SQL and Linq to XML create queries into these data stores This can be direct More often it is done through objects that wrap db tables or XML files and have one public property for each attribute column of the table.

FirstMVCDemoSu10 Model namespace MvcApplication2.Models { public class FileHandler public string path { get; set; } public string[] files { get; set; } public bool GetFiles(string pattern) try int pos = path.LastIndexOf("Home"); path = path.Substring(0, pos) + "Views\\Home"; files = System.IO.Directory.GetFiles(path); return true; } catch { return false; }

What is a View? Views are usually aspx files with only HTML and inline code, e.g., <% … C# code here … %>. Code is used just to support presentation and does no application processing. The HTML is augmented by HTML Helpers, provided by Asp.Net MVC that provide shortcuts for commonly used HTML constructs. Asp.Net MVC comes with jQuery (Javascript) libraries to support reacting to client actions and doing AJAX communication with the server.

FirstMVCDemoSu10 View <%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %> <asp:Content ID="aboutTitle" ContentPlaceHolderID="TitleContent" runat="server"> About Us </asp:Content> <asp:Content ID="aboutContent" ContentPlaceHolderID="MainContent" runat="server"> <h2>Demo Application</h2> <% try { string[] files = ((MvcApplication2.Models.FileHandler)Model).files; Response.Write("<br/>Find Files in Home Controller's Views Folder"); foreach (string file in files) Response.Write("<br/>" + file); string path = ((MvcApplication2.Models.FileHandler)Model).path; System.IO.FileInfo fi = new System.IO.FileInfo(path + "\\Index.Aspx"); Response.Write("<p/>Index.Aspx Last Revised: " + fi.LastAccessTime.ToString()); } catch { Response.Write("<p/>Error finding path or file"); } %> <p> This application is intended to host a set of tutorial demos for Asp.Net MVC. Each Tab will open a new demo example. Eventually I will segregate them into demo categories with a controller for each category. </p>

What is a Controller? A controller is a C# file with controller classes that derive from the class Controller. A controller defines some category of processing for the application. Its methods define the processing details. Routing to a controller is defined in the Global.Asax.cs file. Its default processing is usually what you need.

FirstMVCDemoSu10 Controller namespace MvcApplication2.Controllers { [HandleError] public class HomeController : Controller public ActionResult Index() ViewData["Message"] = "First Model-View-Controller Demos"; return View(); } public ActionResult Form() ViewData["Message"] = "Form not yet implemented"; // code removed here to fit on slide public ActionResult About() string path = Server.MapPath("."); Models.FileHandler fh = new Models.FileHandler(); fh.path = path; fh.GetFiles("*.*"); return View(fh);

Web Application Development Create a new Asp.Net MVC project Delete any part of that you don’t need Add a controller for each category of processing in your application: A category is usually a few pages and db tables that focus on some particular application area Add methods to each controller for each request you wish to handle. Add views as needed for each controller action Add Model classes to support the application area: Each model class has public properties that are synchronized with data in the model db or XML file.

An Opinion This Asp.Net MVC structure is very flexible: You can have as many application categories as you need, simply by adding controllers. The controllers keep the application well organized. You can have as many views as you need. The navigation is simple and provided mostly by the MVC infrastructure, e.g., routing in Global.asax.cs. You can have as many models as you need. Just add classes and use Linq to access the data.

Things you need to know LINQ – Language integrated query Linq to XML and Linq to SQL are commonly used by models to provide data needed by a controller for one of its views. Jquery – Javascript Query library Jquery is frequently used by views to react to client actions in the browser. Jquery has facilities to use AJAX to retrieve small amounts of information from the server without loading a new view.

References Class Text: “Pro Asp.Net MVC” Asp.Net MVC Tutorials Linq: http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx http://nerddinnerbook.s3.amazonaws.com/Intro.htm Linq: http://dotnetslackers.com/articles/csharp/introducinglinq1.aspx Jquery http://docs.jquery.com/Tutorials:How_jQuery_Works#jQuery:_The_Basics