This document provides an overview of ASP.NET, including its history, the MVC pattern, routing, controllers, models, views, and filters. It discusses ASP.NET MVC and Web API, comparing their concepts. Finally, it briefly introduces ASP.NET 5 and some of its key differences from earlier ASP.NET versions like the removal of Web Forms and integration of MVC and Web API into a single framework.
Mobile applications Development - Lecture 12
Javascript
jQuery (Zepto)
useful microframeworks
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
Introduction to ASP.NET MVC, Covering following topics:
Asp.Net Webforms?
Web-Forms : Request Flow
Problems with Web-Forms Approach
Why does Microsoft need MVC?
What is MVC?
Asp.Net MVC Request Flow
Example
The REST Architectural Style
Resources
Representations
Actions
Security
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2014.
http://www.ivanomalavolta.com
Mobile applications Development - Lecture 12
Javascript
jQuery (Zepto)
useful microframeworks
This presentation has been developed in the context of the Mobile Applications Development course at the Computer Science Department of the University of L’Aquila (Italy).
http://www.di.univaq.it/malavolta
Introduction to ASP.NET MVC, Covering following topics:
Asp.Net Webforms?
Web-Forms : Request Flow
Problems with Web-Forms Approach
Why does Microsoft need MVC?
What is MVC?
Asp.Net MVC Request Flow
Example
The REST Architectural Style
Resources
Representations
Actions
Security
This presentation has been developed in the context of the Mobile Applications Development course, DISIM, University of L'Aquila (Italy), Spring 2014.
http://www.ivanomalavolta.com
AngularJS 1.x - your first application (problems and solutions)Igor Talevski
We will talk about all aspects of building a single page application with AngularJS, and we will discuss real examples from day-to-day work. We will also cover a large amount of theory about general web development, best practices, and today's client demands. We will focus on three (3) main points: architecture, security, and real time notification.
AngularJS 1.x - your first application (problems and solutions)Igor Talevski
We will talk about all aspects of building a single page application with AngularJS, and we will discuss real examples from day-to-day work. We will also cover a large amount of theory about general web development, best practices, and today's client demands. We will focus on three (3) main points: architecture, security, and real time notification.
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the -what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
ASP.NET MVC_Routing_Authentication_Aurhorization.pdfsetit72024
Introduction:
Begin with an overview of the .NET MVC framework and its importance in building dynamic and scalable web applications.
Introduce the key concepts that will be covered in the presentation: Attribute Routing, Authentication, and Authorization.
Highlight the significance of these features in enhancing the security, usability, and structure of MVC applications.
Section 1: Attribute Routing in .NET MVC:
Definition and Purpose:
Define Attribute Routing and explain its role in defining routes using attributes directly within the controller and action methods.
Emphasize the benefits of attribute routing in terms of readability, maintainability, and providing fine-grained control over URL patterns.
Syntax and Examples:
Provide examples of attribute routing syntax within controllers and actions.
Demonstrate how attribute routing allows developers to create custom, SEO-friendly, and RESTful URLs.
Showcase scenarios where attribute routing excels over convention-based routing.
Section 2: Authentication in .NET MVC:
Understanding Authentication:
Define Authentication and discuss its importance in verifying the identity of users accessing an application.
Introduce the authentication mechanisms supported by .NET MVC, such as Forms Authentication, Windows Authentication, and OAuth.
Implementing Authentication:
Walk through the process of implementing authentication in .NET MVC using attributes, filters, and middleware.
Discuss the role of the [Authorize] attribute and how it restricts access to specific controllers or actions based on the user's authentication status.
Section 3: Authorization in .NET MVC:
Overview of Authorization:
Define Authorization and distinguish it from authentication.
Emphasize the significance of controlling access to specific resources based on user roles, claims, or other criteria.
Implementing Authorization:
Discuss how authorization can be implemented in .NET MVC using attributes like [Authorize] and [AllowAnonymous].
Explore scenarios where role-based authorization and custom policies are essential.
Provide examples of how to implement role-based access control and attribute-based access control.
Case Studies and Best Practices:
Present real-world case studies or examples showcasing the effective use of attribute routing, authentication, and authorization in .NET MVC projects.
Share best practices for maintaining a secure and well-structured MVC application, including tips on managing user roles, securing sensitive data, and handling authentication cookies.
Conclusion:
Summarize the key takeaways from the presentation.
Reinforce the importance of attribute routing, authentication, and authorization in building robust and secure .NET MVC applications.
Encourage further exploration through resources, documentation, and community forums.
ASP.NET Web API is a framework that makes it easy to build HTTP services that reach a broad range of clients, including browsers and mobile devices. ASP.NET Web API is an ideal platform for building RESTful applications on the .NET Framework.
A simple presentation to understand what is ASP.net MVC4 and its structure.It covers all important features of MVC4 and razor view engine including screenshots
(ATS6-DEV03) Building an Enterprise Web Solution with AEPBIOVIA
In this session, we'll take a deep dive into building an Enterprise Solution with AEP. We'll be using Pipeline Pilot to develop the protocols that will provide our server-side implementations and ExtJS to build the user interface. We'll look at the techniques involved in using protocols to implement actions and explore the capabilities of ExtJS to produce powerful enterprise applications.
Sitecore is making a move: the shift from Sitecore's web forms to Sitecore MVC has been a gradual one, but it's ramping up quickly. Stay in the know with this primer on what it is and why it's important
Getting started with MVC 5 and Visual Studio 2013Thomas Robbins
The ASP.NET MVC Framework provides a powerful Model View Controller (MVC) approach to building web applications and provides separation of concerns, control over HTML output, intuitive URLs, and increased testability. We will start by looking at the what and why of ASP.NET MVC. Then we will explore the various pieces of ASP.NET MVC including routes, controllers, actions, and views. If you are looking to get started with MVC then don’t miss this session.
Forklift Classes Overview by Intella PartsIntella Parts
Discover the different forklift classes and their specific applications. Learn how to choose the right forklift for your needs to ensure safety, efficiency, and compliance in your operations.
For more technical information, visit our website https://intellaparts.com
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
Quality defects in TMT Bars, Possible causes and Potential Solutions.PrashantGoswami42
Maintaining high-quality standards in the production of TMT bars is crucial for ensuring structural integrity in construction. Addressing common defects through careful monitoring, standardized processes, and advanced technology can significantly improve the quality of TMT bars. Continuous training and adherence to quality control measures will also play a pivotal role in minimizing these defects.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Overview of the fundamental roles in Hydropower generation and the components involved in wider Electrical Engineering.
This paper presents the design and construction of hydroelectric dams from the hydrologist’s survey of the valley before construction, all aspects and involved disciplines, fluid dynamics, structural engineering, generation and mains frequency regulation to the very transmission of power through the network in the United Kingdom.
Author: Robbie Edward Sayers
Collaborators and co editors: Charlie Sims and Connor Healey.
(C) 2024 Robbie E. Sayers
5. ASP.NET MVC
• A new presentation option for ASP.NET
• Simpler way to program ASP.NET
• Easily testable and TDD friendly
• More control over your <html/>
• More control over your URLs
• Supports existing ASP.NET features
• Removes: viewstate and postback needs
7. Routing - example
public class OrdersController : Controller
{
public ActionResult Index()
{
}
public ActionResult Details(int id)
{
}
}
http://www.yoursite.com/Orders/Details/1
13. Controller
public class OrdersController : Controller
{
public ActionResult Details(int? id)
{
Order order = db.Orders.Find(id);
if (order == null)
return HttpNotFound();
return View(order);
}
}
View("MyWonderfulOrderView", order);
14. Controller – routing and HTTP methods
public class OrdersController : Controller
{
// GET: Orders/Edit/5
public ActionResult Edit(int? id)
{
}
// POST: Orders/Edit/5
[HttpPost]
public ActionResult Edit(Order order)
{
}
}
18. View
• Related to controllers/actions by naming convetion
• Several View Engine. Standard: Razor, WebFormViewEngine
• Support layouts and partial views
• Can use strongly-typed model (e.g. Order) or dynamic one (ViewBag)
• @Html helper methods (e.g. @Html.TextBoxFor)
• @Html methods can be extended
19. ActionResult
• ActionResult is the base class for action’s return types
• Available results:
• ViewResult - Renders a specifed view to the response stream
• RedirectResult - Performs an HTTP redirection to a specifed URL
• RedirectToRouteResult - Performs an HTTP redirection to a URL that is determined by
the routing engine, based on given route data
• JsonResult - Serializes a given ViewData object to JSON format
• ContentResult - Writes content to the response stream without requiring a view
• FileContentResult - Returns a file to the client
• and more
20. Model binder
• Transform values from client to .NET class instances or primitive types
• Retrieves values from HTML form variables, POSTed variables, query string
and routing parameters
• DefaultModelBinder is the default binder
• Binding can be customized, for specific types at application level or at action’s
parameter level
21. Filters
• Enable Aspect Oriented Programming (AOP)
• Different types for different needs:
• Authorization filters – IAuthorizationFilter
• Action filters – IActionFilter
• Result filters – IResultFilter
• Exception filters – IExceptionFilter
• Filters can be applied to a single action or a whole controller
23. ASP.NET Web API
• Formerly part of WCF framework
• 2012 – First release
• 2013 – Release of Web API 2
• First class framework for HTTP-based services
• Foundamental for creating RESTful services
• Self-hosted
• Different stacks, same concepts – System.Web.Mvc System.Web.Http
24. ASP.NET Web API cf. MVC
• Similar route patterns declarations
• Request/method name matching by HTTP verbs
config.MapHttpAttributeRoutes();
config.Routes.MapHttpRoute(
name: "DefaultApi",
routeTemplate: "api/{controller}/{id}",
defaults: new { id = RouteParameter.Optional }
25. ASP.NET Web API cf. MVC
GET http://www.yoursite.com/api/Orders/5
public class OrdersController : ApiController
{
IQueryable<Order> GetOrders() { … }
IHttpActionResult GetOrder(int id) { … }
IHttpActionResult PutOrder(int id, Order order) { … }
IHttpActionResult PostOrder(Order order) { … }
IHttpActionResult DeleteOrder(int id) { … }
}
26. ASP.NET Web API cf. MVC
• No views or ActionResult just data or IHttpActionResult
• Data are serialized in JSON or other format (e.g. XML)
• Controllers inherit from ApiController
• No more HttpContext.Current
• View filters
27. ASP.NET Web API - OData
“An open protocol to allow the creation and consumption of queryable and
interoperable RESTful APIs in a simple and standard way”
EnableQueryAttribute
Implements out of the box most of the OData query system: filters, pagination,
projection, etc.
31. ASP.NET 5 – .NET Core
• Totally modular
• Faster development cycle
• Seamless transition from on-premises to cloud
• Choose your editor and tools
• Open-source
• Cross-platform
• Fast
32. ASP.NET 5 cf. ASP.NET 4.X
• No more Web Forms and Web API only MVC
• One ring stack to rule them all, i.e. no more double coding
• Tag helpers – cleaner HTML views
• Project and configuration files in JSON
• Server side and client side packages completelly decoupled
• much more
33. thank you for your attention
stay tuned for next workshops
Andrea Vallotti, ph.D
andrea.vallotti@commitsoftware.it
Editor's Notes
1970s – First «implemetation»
1988 – Described as a pattern
several interpretations
mainly used in GUI
clear division between domain objects that model our perception of the real world, and presentation objects that are the GUI elements we see on the screen
one model – multiple views (even command line)
Given an URL, the routing engine is in charge of:
invoking the correct controller and method (called action);
parsing the parameters contained in it.
By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController;
Then it will look for an action (i.e. a method) named Details;
Routing engine will also try to parse the URL looking for parameter which should be passed to
By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController;
Then it will look for an action (i.e. a method) named Details;
Routing engine will also try to parse the URL looking for parameter which should be passed to
By naming convetion routing engine will look for a controller (i.e. a class) named OrdersController;
Then it will look for an action (i.e. a method) named Details;
Routing engine will also try to parse the URL looking for parameter which should be passed to
Standard way of defining routing convention/pattern;
Several definitions can be added;
Priority based on order;
Segment defaults or optional.
Highly customizable
Integrated with the "standard approach";
What is a controller:
it is a class which derives from Controller class;
it exposes public methods which return ActionResult or subclasses of the latter (see in detail later);
these methods are called actions;
Inside the action usually:
it gets a model and acts on it;
then select a View (by default the view has the same name of the action) and pass to it the model
Other ways to pass data to the View: ViewBag: dynamic, property of the controller
Stateless
As a rule of thumb actions name must be different even if signatures differ otherwise routing is not able to choose the correct method for a given URL
You can have more more methods with the same name by specifing the HTTP method:
AcceptVerbsAttribute
HttpDeleteAttribute
HttpGetAttribute
HttpHeadAttribute
HttpOptionsAttribute
HttpPatchAttribute
HttpPostAttribute
HttpPutAttribute
The Model of MVC is intended to be a "View Model" (example default UserLoginModel)
However also the Business Model can be used
You can use validation attribute to let MVC validate the user input
The Model of MVC is intended to be a "View Model" (example default LoginViewModel)
However also the Business Model can be used
You can use validation attribute to let MVC validate the user input
You can also use attribute to help rendering the view
System.ComponentModel.DataAnnotations
Helper, Bundle, etc.
By default all the views are placed in Views/<controller name>/<action name>.cshtml
Each project can use its preferred View Engine
There are also third-party View Engine which allow to use RoR or Django syntax
Layouts are like master pages in old ASP.NET
Different layouts can be used for different sections of the application (using Layout property)
Strongly-typed using @model directive, dynamic using ViewBag
ViewBag can be used by the View (even in strongly-typed) to pass information to the layout and partial views
Html helper methods can be used to render standard html elements
Helper, Bundle, etc.
Usually action’s return type is ActionResult but you can be more specific using a derived class
DefaultModelBinder creates an empty instance and fills it with values received from client
The default binder can be changed using ModelBinders.Binders.DefaultBinder
We will see a customization example during the demo
Filters are executed in the order listed
Authorization filters are used to implement authentication and authorization for controller actions
You can use an action filter, for instance, to modify the view data that a controller action returns.
Result filters - you might want to modify a view result right before the view is rendered to the browser.
You can use an exception filter to handle errors raised by either your controller actions or controller action results. You also can use exception filters to log errors.
System.Web.Mvc.FilterAttribute base class
WCF – Windows Communication Foundation is mainly aimed to SOAP-based services
ASP.NET MVC relies on IIS (standard or express) while ASP.NET Web API can be self-hosted
Routing - same declaration style, different classes
By default action are matched by HTTP verbs not segment of URL
GET http://www.yoursite.com/api/Orders/5 OrdersController.GetOrder(5)
Data are serialized in JSON or XML based on Accept header of HTTP request
Web API was design to work without a web server (i.e. IIS) and with async framework therefore you should never use HttpContext.Current especially when self-hosted
Web API is responsible to pass the correct context to each operation
Action, Authorization and Exception filters are still available
Basically OData is a way to standardize REST services, e.g. by defining how to filter
It is «simply» an action filter which works with an IQueryable
.NET Core 5:
is the version of .NET that runs on Mac, Windows and Linux;
brings features via packages framework much smaller;
ASP.NET 5 runs both on .NET Framework 4.6 and .NET Core;
Totally modular – cause all the library (such as MVC, file, etc.) have been stripped from the core you have to download them with NuGet
Faster development cycle – simply modify the code and refresh your page, the code will be automatically compiled
Seamless transition – the application runs with its own framework and libraries therefore you do not need to install «special» stuff on the server
Editor and tools – Visual Studio, Visual Studio Code on all platforms but through OmniaSharp also emacs, sublime, etc. are supported. Yeoman generator!!!
Cross-platform – Kestrel is a standalone web server based on libuv (the same as Node.JS),
Fast benchmarks show that ASP.NET 5 is faster than Node.JS
ASP.NET 5 only MVC which contains both old MVC and Web API
One stack one Controller base class, one routing configuration, model binding, etc.
All controllers can have actions which return ActionResult or data
System.Web.* does not exist anymore we have the package Microsoft.AspNet.Mvc
Tag helpers just like angular directive, allows to write more HTML and take advantage of intellisense for CSS and HTML
JSON files no more XML, JSON is easier to understand and widely used
Server/client side NuGet for the server and Bower for the client
Vi rigrazio per l’attenzione e spero di essere riuscito a sintetizzare un argomento che richiede molti approfondimenti.
Qui trovate i miei contatti e sono a disposizione al desk per un veloce incontro per rispondere a tutte le vostre domande.
Grazie ancora e buon forum a tutti.