Chapter 7 (w6) ASP - NET Overview
Chapter 7 (w6) ASP - NET Overview
Web Programming
CHAPTER 7
ASP.NET MVC5Overview
Web Programming
Web Programming
DESIGN PATTERNS
Design patterns represent solutions to problems that arise when developing
software within a particular context.
Patterns facilitate reuse of successful software architectures and designs and
help document systems.
Patterns explicitly capture expert knowledge and design tradeoffs and make
it more widely available
Patterns help improve developer communication
Pattern names form a common vocabulary
Web Programming
MVC PATTERN
Web Programming
What is MVC?
•Model–view–controller (MVC) is a software architecture pattern
•Code reusability and separation of concerns
Web Programming
Model
Set of classes that describes the data we are working with as well as the business
Rules for how the data can be changed and manipulated. May contain data validation rules
Often encapsulate data stored in a database as well as code used to manipulate the data
Most likely a Data Access Layer of some kind
Apart from giving the data objects, it doesn’t have significance in the framework
Web Programming
View
Defines how the application’s user interface (UI) will be displayed
May support master views (layouts) and sub-views (partial views or controls)
Controller
The core MVC component
Process the requests with the help of views and models
A set of classes that handles communication from the user
Overall application flow
Application-specific logic
Every controller has one or more "Actions"
Web Programming
MVC Frameworks
CakePHP(PHP)
CodeIgniter (PHP)
Spring (Java)
Perl: Catalyst, Dancer
Python: Django, Flask, Grok
Ruby: Ruby on Rails, Camping, Nitro, Sinatra
JavaScript: AngularJS, JavaScriptMVC, Spine
ASP.NET MVC (.NET Framework)
Web Programming
Programming, sc
ripting,
and markup lang
uages
https://survey.stackoverflow.co/2022/
Web Programming
Web framework
s and technologi
es
https://survey.stackoverflow.co/2022/
Web Programming
ASP.NET MVC
Web Programming
https://www.aceinfoway.com/blog/
dotnet-maze-comparison
Web Programming
.NET Framework
A platform for creating and running Windows apps.
The .NET framework consists of developer tools, programming languages,
and libraries used to create desktop and web applications.
Games, web services, and websites can also be built using the .NET
framework.
The framework has been designed such that it can be used with any of these
common languages: c#, c++, Visual Basic, JScript, Cobol, etc.
Also, more than 60 programming languages are supported by the .NET
Framework, 11 of which were created and developed by Microsoft.
Web Programming
ASP.NET
ASP.NET is the Microsoft platform for developing Web Applications.
Using ASP.NET you can create e-commerce sites, data driven portals and just
about anything else you can find on the internet.
You don't need to paste together a jumble of HTML and JavaScript code.
Instead you can create full scale web apps by leveraging your knowledge of C#
coding and a design tool like Visual Studio.
Web Programming
ASP.NET MVC
MVC is a design pattern used to decouple
user-interface (view),
data (model),
application logic (controller).
Separationof Concerns
•Each component has one responsibility
•SRP–Single Responsibility Principle
•DRY–Don’t Repeat Yourself
•More easily testable
•TDD–Test-driven development
•Helps with concurrent development
•Performing tasks concurrently
•One developer works on views
•Another works on controllers
Web Programming
Extensible
•Replace any component of the system
•Interface-based architecture
•Almost anything can be replaced or extended
•Model binders (request data to CLR objects)
• The Common Language Runtime (CLR) is programming that manages the execution of
programs written in any of several supported languages, allowing them to share common
object-oriented classes written in any of the languages. It is a part of Microsoft's . NET
Framework.
•Action/result filters (e.g. OnActionExecuting)
•Custom action result types
•View engine (Razor, WebForms, NHaml, Spark)
•View helpers (HTML, AJAX, URL, etc.)
•Custom data providers (ADO.NET), etc.
• ADO.NET is a set of classes that expose data access services
Web Programming
The Technologies
•Technologies that ASP.NET MVC uses
•C# (OOP, Unit Testing, async, etc.)
•HTML(5) and CSS
•JavaScript (jQuery, React, KendoUI, etc.)
•AJAX, Single-page apps
•Databases (MS SQLandothers)
•ORM (Entity Framework and LINQ)
• Object Relation Mapping (ORM) is used for data processing from a relational database to
modeling (logical objects or domain classes) in the programming that is more easily usable
by code.
MVC5 FEATURES
•ASP.NET Identity
•Bootstrap templates
•Attribute Routing
•ASP.NET scaffolding
•Authentication filters
Web Programming
ASP.NET Identity
• Testability: Allows to write unit tests for user-related application code.
• Login providers: Rather than just focusing on username / password
authentication, ASP.NET Identity understands that users often are
authenticated through social providers (for example, Microsoft Account,
Facebook, or Twitter) and Windows Azure Active Directory
• NuGet distribution is installed in your applications as a NuGet package.
• NuGet : An essential tool for any modern development platform is a mechanism through which
developers can create, share, and consume useful code. Often such code is bundled into "packages"
that contain compiled code (as DLLs) along with other content needed in the projects that consume
these packages.
Web Programming
Bootstrap Templates
When you created a new MVC project and ran it, you got a white square on a
blue background
Web Programming
MVC Routing
• Routing is a process of mapping the browser request to the controller action and return
response back.
• Each MVC application has default routing for the default HomeController.
• We can set custom routing for newly created controller.
• The RouteConfig.cs file is used to set routing for the application.
Web Programming
Attribute Routing
uses attributes to define routes.
Attribute routing gives you more control over the URIs in your web application.
For example, a socially enhanced e-commerce website could have the following routes:
It includes support for building powerful custom scaffolders, complete with custom
dialogs and a comprehensive scaffolding API.
Web Programming
Authentication Filters
ASP.NET MVC filters are used to add extra logic at the different levels of MVC
Framework request processing.
• Authentication Filter runs before any other filter or action method.
• Authentication confirms if you are a valid or invalid user.
• These filters implement the IAuthenticationFilter interface and
ActionFilterAttribute base class.
Web Programming
31
Web Programming
The /Content and /Scripts directories, you’ll find the CSS files
that is used to style all HTML on the site, as well as JavaScript
libraries that can enable jQuery* support within the application