Murach: An introduction to web programming with ASP.NET Core MVCMahmoudOHassouna
Murach: An introduction to web programming with ASP.NET Core MVC
Mary Delamater, Joel Murach - Murach's ASP.NET Core MVC-Mike Murach & Associates, Inc. (2020) (1)
The document describes how to build a Movie List application using ASP.NET MVC and Entity Framework Core by explaining how to set up the model classes, controllers, views, and database context to display, add, edit and delete movie data, relating movies to genres and making the URLs more user-friendly. It provides code examples for each part of the application.
Murach: How to validate data in asp.net core mvcMahmoudOHassouna
- You can validate user-input data in ASP.NET MVC using data attributes on model properties and custom validation attributes. Data attributes like Required, Range, StringLength allow property-level validation, while custom attributes can perform cross-field and custom validation logic.
- Client-side validation is enabled by default and prevents invalid submissions, but server-side validation in the controller is also needed as the only authorization. You can customize validation error messages and UI.
Murach: An introduction to web programming with ASP.NET Core MVCMahmoudOHassouna
Murach: An introduction to web programming with ASP.NET Core MVC
Mary Delamater, Joel Murach - Murach's ASP.NET Core MVC-Mike Murach & Associates, Inc. (2020) (1)
The document describes how to build a Movie List application using ASP.NET MVC and Entity Framework Core by explaining how to set up the model classes, controllers, views, and database context to display, add, edit and delete movie data, relating movies to genres and making the URLs more user-friendly. It provides code examples for each part of the application.
Murach: How to validate data in asp.net core mvcMahmoudOHassouna
- You can validate user-input data in ASP.NET MVC using data attributes on model properties and custom validation attributes. Data attributes like Required, Range, StringLength allow property-level validation, while custom attributes can perform cross-field and custom validation logic.
- Client-side validation is enabled by default and prevents invalid submissions, but server-side validation in the controller is also needed as the only authorization. You can customize validation error messages and UI.
This document discusses creating an MVC application from scratch using LINQ to SQL to perform CRUD operations on a database. It covers:
1. Creating an empty MVC project and adding controllers, views and models
2. Creating a sample database and using LINQ to SQL for communication between the MVC app and database
3. Performing CRUD operations in the MVC app by querying the database and passing data between controllers and views
This document discusses moving existing websites with security issues to the ASP.NET MVC framework using Entity Framework. It provides an overview of MVC and EF, how to set them up in Visual Studio, and examples of using them to improve security by removing direct SQL queries and moving more logic to the server. Key benefits highlighted include built-in features for validation and preventing cross-site request forgery attacks. Examples demonstrate querying databases and validating models without writing direct SQL or adding additional code.
.NET Core, ASP.NET Core Course, Session 11aminmesbahi
The document discusses views in ASP.NET Core MVC, including:
- Views are HTML templates that generate content to send to the client and use Razor syntax to interact code and HTML.
- Views are typically stored in the Views folder within the application and organized by controller.
- Partial views are reusable parts of web pages that can be rendered within other views to reduce duplication.
- Data can be passed to views using strongly typed view models or loosely with ViewData/ViewBag. Partial views have access to parent view's data by default.
This document provides instructions for creating a simple tasklist application using ASP.NET MVC. It describes creating the controller, views, database, and model. The controller contains actions for listing, creating, and completing tasks. Views are created for displaying the task list and creating new tasks. A database with a Tasks table is set up using LINQ to SQL. Logic is added to the controller actions to retrieve and save tasks from the database. The task list view is modified to display tasks from the model.
The document introduces cookies and how they are handled in Oracle Application Testing Suite: e-Tester. It discusses the two types of cookies - persistent and session cookies. It also describes how the cookie handling options can be configured on a per-script basis and the implications of these settings for stand-alone versus linked scripts.
A plug-in is piece of code written in a standard JavaScript file. These files provide useful jQuery methods which can be used along with jQuery library methods.
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
video :
https://youtu.be/qsBe9X9n_-M
Courtesy:
http://www.ifourtechnolab.com
This document discusses several key concepts in ASP.NET MVC including areas, HTML helpers, partial views, dependency injection, model validation, and asynchronous controller actions. It provides code examples for creating an area, partial view, unit tests, and using model attributes for validation. The document is intended to be part of an ASP.NET MVC training and covers important topics like routing, generating HTML, reusing views, testing, and asynchronous programming.
This document discusses component interfaces in PeopleSoft. It defines a component interface as a means to access PeopleSoft applications without using PeopleSoft pages. Component interfaces expose PeopleSoft components for synchronous access from external applications. This allows external applications to access underlying data and business logic without needing to understand page structures and component definitions. The document then describes the key elements and architecture of component interfaces, including components, properties, collections, methods, and how to create and work with component interfaces.
This document provides an introduction and overview of ASP.NET Identity. It discusses how ASP.NET Identity is the new membership system for building ASP.NET web applications and allows using social identities like Windows Live, Gmail, Facebook and Twitter for authentication. The document outlines key features of ASP.NET Identity like extended user account definitions, two-factor authentication, account confirmation and management of users and roles. It also lists required packages and describes important pieces of ASP.NET Identity like User, Role, User Manager, Role Manager and Authentication Manager. Finally, it provides references for further reading on ASP.NET Identity.
SQLite is an embedded SQL database that contains a C library. It is not a client-server database and instead embeds directly into the end program. SQLite follows PostgreSQL syntax. To connect with SQLite from Python, you import the sqlite3 module and use the connect() method to create a Connection object. From there you can create a Cursor object to execute SQL statements like CREATE TABLE, INSERT, SELECT, WHERE, ORDER BY, UPDATE, and DELETE.
The document provides an introduction to Oracle Application Testing Suite e-Load and its features for load testing web applications, including setting up virtual users and profiles, running load tests, and analyzing results. It describes how to configure e-Load settings for aspects like authentication, browser emulation, caching, and download management to simulate real user behavior under load.
The document provides an overview of Angular including:
- Angular is an open source JavaScript framework for building web applications in HTML and JavaScript. It provides services and objects to create applications faster.
- Typescript is a programming language that adds optional static typing to JavaScript. It compiles to JavaScript.
- Modules, components, templates, metadata, services, and routes are architectural concepts in Angular that define application structure and functionality.
- Components control views and consist of templates, classes, and metadata. Services provide shared functionality across modules. Routes enable navigation between views.
This document provides an introduction to ASP.NET MVC, covering the MVC pattern, controllers, actions, routing, views, models, and capturing user input with forms. It discusses key ASP.NET MVC concepts like separation of concerns, the default project structure, and common action filters. The document also provides exercises for readers to create a basic MVC application with a model, controller actions, and views that display and capture data. It concludes by outlining additional topics to be covered in part 2, such as HTML helpers, partial views, and unit testing.
Learning MVC Part 3 Creating MVC Application with EntityFrameworkAkhil Mittal
This document discusses connecting an existing MVC application to a database using Entity Framework instead of LINQ to SQL. It provides steps to generate an Entity Data Model from an existing database, generate strongly typed entity classes, and modify the application's controllers to use the Entity Framework context instead of the LINQ to SQL context. The key steps are: 1) Adding an Entity Data Model file and generating entity classes; 2) Modifying controllers to use the Entity Framework context instead of LINQ to SQL; 3) Binding views to the generated entity classes. The document emphasizes that Entity Framework automates CRUD operations and allows focusing on business logic rather than data access code.
Data banks in Oracle Application Testing Suite allow test scripts to be iterated multiple times with different input data by mapping form fields to variables populated from an external data file. This enables automated testing of multiple input combinations without manually re-running the test case each time. The data file must be in CSV format and stored in the databank folder. The data bank wizard is used to map parameters to variables and bind variables to data fields to link the script and data file.
This document provides an overview of different types of PeopleCode events in PeopleSoft applications. It discusses page events like Activate and component events like FieldChange, RowInsert, and SaveEdit. Each event is described in 1-2 sentences explaining what it is and when it fires. The document also notes what types of objects (pages, fields, etc.) each event can be associated with.
SPFarm objects represent the highest level in the SharePoint hierarchy as they represent the entire SharePoint farm. SPSite objects represent site collections, which are the largest objects users typically interact with. SPWeb objects represent individual websites within a site collection and contain things like actual content. Visual Web Part projects include a default user control and preconfigured web part to load the control, Sequential workflows have a defined start and end while State Machine workflows allow items to move between states without a predefined order.
- The document discusses techniques for efficient and thread-safe database access from web servers including using synchronized blocks, prepared statements, and connection pooling.
- Synchronized blocks allow only one thread to execute a block of code at a time to prevent race conditions when multiple threads access a shared resource like a database.
- Prepared statements improve efficiency by parsing SQL statements once instead of each time they are executed, allowing values to be bound dynamically.
- Connection pooling reuses existing database connections instead of creating new ones for each request, improving performance.
The document describes how to use Mulesoft to connect a CSV file to a Salesforce account. It involves using a File connector to monitor an input folder for CSV files. A Salesforce connector is configured with a username, password and security token. A DataMapper transformer maps the CSV file fields to Salesforce object fields. When run, the application will take CSV contact data from the input folder and upload it to the Salesforce account as new contacts.
This document provides an overview of ASP.net MVC, including what MVC is, how ASP.net MVC request execution works, details on controllers, routing, application development, differences from web forms, and when to use MVC. It describes MVC as separating applications into models, views, and controllers, and how ASP.net MVC implements the MVC pattern with controllers handling user input and selecting views. Request processing and controller lifecycles are also summarized at a high level.
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
This document discusses creating an MVC application from scratch using LINQ to SQL to perform CRUD operations on a database. It covers:
1. Creating an empty MVC project and adding controllers, views and models
2. Creating a sample database and using LINQ to SQL for communication between the MVC app and database
3. Performing CRUD operations in the MVC app by querying the database and passing data between controllers and views
This document discusses moving existing websites with security issues to the ASP.NET MVC framework using Entity Framework. It provides an overview of MVC and EF, how to set them up in Visual Studio, and examples of using them to improve security by removing direct SQL queries and moving more logic to the server. Key benefits highlighted include built-in features for validation and preventing cross-site request forgery attacks. Examples demonstrate querying databases and validating models without writing direct SQL or adding additional code.
.NET Core, ASP.NET Core Course, Session 11aminmesbahi
The document discusses views in ASP.NET Core MVC, including:
- Views are HTML templates that generate content to send to the client and use Razor syntax to interact code and HTML.
- Views are typically stored in the Views folder within the application and organized by controller.
- Partial views are reusable parts of web pages that can be rendered within other views to reduce duplication.
- Data can be passed to views using strongly typed view models or loosely with ViewData/ViewBag. Partial views have access to parent view's data by default.
This document provides instructions for creating a simple tasklist application using ASP.NET MVC. It describes creating the controller, views, database, and model. The controller contains actions for listing, creating, and completing tasks. Views are created for displaying the task list and creating new tasks. A database with a Tasks table is set up using LINQ to SQL. Logic is added to the controller actions to retrieve and save tasks from the database. The task list view is modified to display tasks from the model.
The document introduces cookies and how they are handled in Oracle Application Testing Suite: e-Tester. It discusses the two types of cookies - persistent and session cookies. It also describes how the cookie handling options can be configured on a per-script basis and the implications of these settings for stand-alone versus linked scripts.
A plug-in is piece of code written in a standard JavaScript file. These files provide useful jQuery methods which can be used along with jQuery library methods.
JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
video :
https://youtu.be/qsBe9X9n_-M
Courtesy:
http://www.ifourtechnolab.com
This document discusses several key concepts in ASP.NET MVC including areas, HTML helpers, partial views, dependency injection, model validation, and asynchronous controller actions. It provides code examples for creating an area, partial view, unit tests, and using model attributes for validation. The document is intended to be part of an ASP.NET MVC training and covers important topics like routing, generating HTML, reusing views, testing, and asynchronous programming.
This document discusses component interfaces in PeopleSoft. It defines a component interface as a means to access PeopleSoft applications without using PeopleSoft pages. Component interfaces expose PeopleSoft components for synchronous access from external applications. This allows external applications to access underlying data and business logic without needing to understand page structures and component definitions. The document then describes the key elements and architecture of component interfaces, including components, properties, collections, methods, and how to create and work with component interfaces.
This document provides an introduction and overview of ASP.NET Identity. It discusses how ASP.NET Identity is the new membership system for building ASP.NET web applications and allows using social identities like Windows Live, Gmail, Facebook and Twitter for authentication. The document outlines key features of ASP.NET Identity like extended user account definitions, two-factor authentication, account confirmation and management of users and roles. It also lists required packages and describes important pieces of ASP.NET Identity like User, Role, User Manager, Role Manager and Authentication Manager. Finally, it provides references for further reading on ASP.NET Identity.
SQLite is an embedded SQL database that contains a C library. It is not a client-server database and instead embeds directly into the end program. SQLite follows PostgreSQL syntax. To connect with SQLite from Python, you import the sqlite3 module and use the connect() method to create a Connection object. From there you can create a Cursor object to execute SQL statements like CREATE TABLE, INSERT, SELECT, WHERE, ORDER BY, UPDATE, and DELETE.
The document provides an introduction to Oracle Application Testing Suite e-Load and its features for load testing web applications, including setting up virtual users and profiles, running load tests, and analyzing results. It describes how to configure e-Load settings for aspects like authentication, browser emulation, caching, and download management to simulate real user behavior under load.
The document provides an overview of Angular including:
- Angular is an open source JavaScript framework for building web applications in HTML and JavaScript. It provides services and objects to create applications faster.
- Typescript is a programming language that adds optional static typing to JavaScript. It compiles to JavaScript.
- Modules, components, templates, metadata, services, and routes are architectural concepts in Angular that define application structure and functionality.
- Components control views and consist of templates, classes, and metadata. Services provide shared functionality across modules. Routes enable navigation between views.
This document provides an introduction to ASP.NET MVC, covering the MVC pattern, controllers, actions, routing, views, models, and capturing user input with forms. It discusses key ASP.NET MVC concepts like separation of concerns, the default project structure, and common action filters. The document also provides exercises for readers to create a basic MVC application with a model, controller actions, and views that display and capture data. It concludes by outlining additional topics to be covered in part 2, such as HTML helpers, partial views, and unit testing.
Learning MVC Part 3 Creating MVC Application with EntityFrameworkAkhil Mittal
This document discusses connecting an existing MVC application to a database using Entity Framework instead of LINQ to SQL. It provides steps to generate an Entity Data Model from an existing database, generate strongly typed entity classes, and modify the application's controllers to use the Entity Framework context instead of the LINQ to SQL context. The key steps are: 1) Adding an Entity Data Model file and generating entity classes; 2) Modifying controllers to use the Entity Framework context instead of LINQ to SQL; 3) Binding views to the generated entity classes. The document emphasizes that Entity Framework automates CRUD operations and allows focusing on business logic rather than data access code.
Data banks in Oracle Application Testing Suite allow test scripts to be iterated multiple times with different input data by mapping form fields to variables populated from an external data file. This enables automated testing of multiple input combinations without manually re-running the test case each time. The data file must be in CSV format and stored in the databank folder. The data bank wizard is used to map parameters to variables and bind variables to data fields to link the script and data file.
This document provides an overview of different types of PeopleCode events in PeopleSoft applications. It discusses page events like Activate and component events like FieldChange, RowInsert, and SaveEdit. Each event is described in 1-2 sentences explaining what it is and when it fires. The document also notes what types of objects (pages, fields, etc.) each event can be associated with.
SPFarm objects represent the highest level in the SharePoint hierarchy as they represent the entire SharePoint farm. SPSite objects represent site collections, which are the largest objects users typically interact with. SPWeb objects represent individual websites within a site collection and contain things like actual content. Visual Web Part projects include a default user control and preconfigured web part to load the control, Sequential workflows have a defined start and end while State Machine workflows allow items to move between states without a predefined order.
- The document discusses techniques for efficient and thread-safe database access from web servers including using synchronized blocks, prepared statements, and connection pooling.
- Synchronized blocks allow only one thread to execute a block of code at a time to prevent race conditions when multiple threads access a shared resource like a database.
- Prepared statements improve efficiency by parsing SQL statements once instead of each time they are executed, allowing values to be bound dynamically.
- Connection pooling reuses existing database connections instead of creating new ones for each request, improving performance.
The document describes how to use Mulesoft to connect a CSV file to a Salesforce account. It involves using a File connector to monitor an input folder for CSV files. A Salesforce connector is configured with a username, password and security token. A DataMapper transformer maps the CSV file fields to Salesforce object fields. When run, the application will take CSV contact data from the input folder and upload it to the Salesforce account as new contacts.
This document provides an overview of ASP.net MVC, including what MVC is, how ASP.net MVC request execution works, details on controllers, routing, application development, differences from web forms, and when to use MVC. It describes MVC as separating applications into models, views, and controllers, and how ASP.net MVC implements the MVC pattern with controllers handling user input and selecting views. Request processing and controller lifecycles are also summarized at a high level.
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
This document summarizes projects completed by Matt Willmer as part of a .NET Masters program. The projects involved building multi-tier applications using technologies like C#, ASP.NET, Windows Forms, SQL Server, and Visual Studio. Project 1 focused on learning C# features like properties and enumerators. Project 2 involved creating a Windows Forms application for a library management system. Project 3 added database functionality using LINQ to SQL. Project 4 created a web-based presentation layer for the library system using ASP.NET.
This document summarizes key aspects of ASP.NET MVC including controllers, actions, returning different result types from actions, passing data to views, using filters, and more. Controllers are responsible for controlling application flow and exposing public methods as actions. Actions can return various result types including ViewResult, RedirectResult, ContentResult, and JsonResult. Data can be passed to views from controllers using ViewData, ViewBag, TempData, and strongly typed models. Filters provide a way to inject extra behaviors into controllers and actions, and common filter types include AuthorizeFilter, HandleErrorFilter, and OutputCacheFilter.
Mvc interview questions – deep dive jinal desaijinaldesailive
Can you describe ASP.NET MVC Request Life Cycle? 1. Receive request, look up Route object in RouteTable collection and create RouteData object. 2. Create RequestContext instance. 3. Create MvcHandler and pass RequestContext to handler. 4. Identify IControllerFactory from RequestContext. 5. Create instance of class that implements ControllerBase. 6. Call MyController.Execute method. 7. The ControllerActionInvoker determines which action to invoke on the controller and executes the action on the controller, which results in calling the model and returning a view.
This document discusses MVC controllers in more detail. It explains that controllers contain action methods that handle requests and return responses. Action methods validate request data, invoke business logic, and select a view or redirect. Parameters can pass data to action methods, which generally return ViewResult or RedirectResult via the IActionResult interface. Controllers follow conventions like ending in "Controller" and inheriting from ControllerBase.
Spring MVC is the web component of the Spring framework. It follows the MVC pattern with controllers handling requests and generating models for views to display. Spring MVC supports annotations for mapping requests to controller methods and binding request parameters to Java objects. It provides validation, internationalization, and AJAX support through integration with other libraries. Common view technologies like JSP are supported through tags that integrate with Spring MVC.
The primary object in the ASP programming model is the ScriptingContext object, which exposes the interaction of the client browser. Because the ScriptingContext object is always available to ASP applications, you don't need to explicitly create a reference to it. The ScriptingContext object contains the six primary ASP objects, five built-in objects, and the ObjectContext object. The five built-in objects are the Application object, the Request object, the Server object, the Sessions object, and the Response object.
1 MVC – Ajax and Modal Views AJAX stands for Asynch.docxhoney725342
1
MVC – Ajax and Modal Views
AJAX stands for Asynchronous JavaScript and XML. It is a client-side capability that allows
silent updates of parts of a web page. Every browser provides a component called
XmlHttpRequest that is invoked via Javascript and has the capability to make asynchronous calls
back to the web server from where the page was obtained. One can set up Javascript timers to
automate the periodic retrieval of data using the XmlHttpRequest object.
Even though we can program the XmlHttpRequest object directly using Javascript, JQuery
makes it a lot easier to set it up and issue an asynchronous request to the web server. ASP.Net
MVC also provides a server-side solution to AJAX via the Ajax.BeginForm extension method.
We will demonstrate the two approaches to AJAX i.e., via JQuery and serializable partial views,
and via the Ajax.BeginForm.
Using SQL Server Management Studo, create a database called ProductsDB. Add a table called
Categories with the folling data.
The CategoryId column is of type int, and the CategoryName column is of type carchar(50).
Add another table called Products with the following design.
Then put the following data in the Products table.
2
Using Visual Studio, create a new project. Choose the web type of project, and select the MVC
template as shown below.
Add the following connection string information to the web.config file. Replace ALPHA with
the name of your database server.
<configuration>
<connectionStrings>
<add name="PRODUCTSDB" connectionString="server=ALPHA;integrated
security=true;database=ProductsDB" />
</connectionStrings>
<appSettings>
Add a class to the Models folder called Category with the following code in it.
public class Category
{
public int CategoryId { get; set; }
public string CategoryName { get; set; }
}
3
Add a folder called DataLayer to the project. Then add an interface called IEntity to it with the
following code in it.
public interface IEntity
{ // any class that needs conversion to a List from a DataTable will implement this
void PopulateFields(DataRow dr);
}
Add a class called MyEntityBase to the Models folder with the following code in it. This class
uses reflection to populate the fields of a class from a given DataRow of a DataTable. All
repository methods that need to convert a DataTable to a list will indirectly use this method via
the generic DBList class..
public class MyEntityBase : IEntity
{
public void PopulateFields(DataRow dr)
{
// use reflection to populate the fields of this class from DataRow
Type tp = this.GetType();
foreach (PropertyInfo pi in tp.GetProperties())
pi.SetValue(this, dr[pi.Name]);
}
}
Add a class called DBList to the DataLayer folder with the following code in it.
class DBList
{
...
This document provides an overview of the key concepts and architecture of Spring MVC, the model-view-controller framework in Spring. It discusses how Spring MVC handles requests and dispatches them to controller methods, and how controllers select views and expose model objects. It also covers view resolution, form processing, validation, exception handling, and REST support in Spring MVC, as well as its configuration options.
ADO.NET by ASP.NET Development Company in india
ADO.NET is a data access technology from the Microsoft .NET Framework that provides communication between relational and non-relational systems through a common set of components.
Video :
Courtesy:
http://www.ifourtechnolab.com
Lyudmila Zharova: Developing Solutions for SharePoint 2010 Using the Client O...SharePoint Saturday NY
The document provides an overview of developing solutions for SharePoint 2010 using the Client Object Model. It discusses the goals and supported areas of the Client Object Model, compares server and client objects, explains how the Client-Side Object Model works using the ClientContext object, and reviews rules for using the Client OM including object identity and authentication. Implementation details are also provided for the .NET, Silverlight, and ECMAScript Client OM.
This document discusses working with servlets and session tracking in Java. It explores the ServletConfig and ServletContext interfaces, and how to implement session tracking using HttpSession, cookies, and URL rewriting. The objectives are to learn how to access configuration information from servlets, set and get attributes in the servlet context, and maintain state across HTTP requests using different session tracking mechanisms.
The document provides an overview of ADO.NET, which is Microsoft's data access technology for .NET applications to connect to and manipulate data in various data stores. It discusses key ADO.NET concepts like connections, commands, data readers, data adapters, datasets and how they are used to work with different data providers like SQL Server, OLE DB, and ODBC. It also covers data binding using data grids and filtering data views.
This document provides an overview of controllers and actions in the MVC framework. It discusses how controllers are responsible for responding to requests, validating actions, and providing data and error handling. It also covers specific controller concepts like ViewData/ViewBag, action attributes, action results, and asynchronous actions.
Core Data allows developers to work with Swift objects and persist them to storage like SQLite. It provides an object graph and change tracking system so objects can be saved, retrieved, and queried. The Core Data stack includes managed objects, managed object contexts, and a persistent store coordinator that interacts with the backend store. Entities in a data model define the structure and relationships of persisted objects.
NicheTech is a company which want to help students in live project training .
NicheTech is a company which provides software services across India.
Nichetech is also providing live project training to MCA, BE , MSC IT students . We are also providing ios training Ahmedabad.
iOS is the best technology for getting job according to current market.
We support students who want to take live project training in iOS , PHP, Java , Android , ASP.NET Ahmedabad.
Nichetech had training more than 600 GTU students .
For live project training Ahmedabad : http://www.liveprojecttraining.in/
iOS Training Ahmedabad : http://www.beprojecttraining.com/ios_live_training.html
Project Training Ahmedabad : http://www.gtuprojecttraining.com/
Building Modern Websites with ASP.NET by Rachel Appel.NET Conf UY
This document provides an overview of building modern websites with ASP.NET MVC, including discussions of models, controllers, views, routing, Entity Framework, and view models. It describes models as the application's data expressed as classes, controllers as handling requests and routing, and views as the UI layer that renders models. It also covers Entity Framework for database mapping, RESTful routing, and using view models to promote separation of concerns.
An assembly in .NET is a collection of types and resources that form a logical unit. Assemblies can contain metadata about types using attributes. Attributes provide additional information that can be attached to classes, methods, and other members. There are built-in attributes in .NET and custom attributes can be created by deriving from the Attribute base class. Built-in attributes like Required and StringLength are used to validate model data in ASP.NET MVC. A custom MyLicenseAttribute was created to require a license key by applying the attribute to assemblies. Attributes help add metadata and customize behavior.
Similar a Murach: How to transfer data from controllers (20)
How to Manage Your Lost Opportunities in Odoo 17 CRMCeline George
Odoo 17 CRM allows us to track why we lose sales opportunities with "Lost Reasons." This helps analyze our sales process and identify areas for improvement. Here's how to configure lost reasons in Odoo 17 CRM
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Iván Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
हिंदी वर्णमाला पीपीटी, hindi alphabet PPT presentation, hindi varnamala PPT, Hindi Varnamala pdf, हिंदी स्वर, हिंदी व्यंजन, sikhiye hindi varnmala, dr. mulla adam ali, hindi language and literature, hindi alphabet with drawing, hindi alphabet pdf, hindi varnamala for childrens, hindi language, hindi varnamala practice for kids, https://www.drmullaadamali.com
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
Chapter wise All Notes of First year Basic Civil Engineering.pptxDenish Jangid
Chapter wise All Notes of First year Basic Civil Engineering
Syllabus
Chapter-1
Introduction to objective, scope and outcome the subject
Chapter 2
Introduction: Scope and Specialization of Civil Engineering, Role of civil Engineer in Society, Impact of infrastructural development on economy of country.
Chapter 3
Surveying: Object Principles & Types of Surveying; Site Plans, Plans & Maps; Scales & Unit of different Measurements.
Linear Measurements: Instruments used. Linear Measurement by Tape, Ranging out Survey Lines and overcoming Obstructions; Measurements on sloping ground; Tape corrections, conventional symbols. Angular Measurements: Instruments used; Introduction to Compass Surveying, Bearings and Longitude & Latitude of a Line, Introduction to total station.
Levelling: Instrument used Object of levelling, Methods of levelling in brief, and Contour maps.
Chapter 4
Buildings: Selection of site for Buildings, Layout of Building Plan, Types of buildings, Plinth area, carpet area, floor space index, Introduction to building byelaws, concept of sun light & ventilation. Components of Buildings & their functions, Basic concept of R.C.C., Introduction to types of foundation
Chapter 5
Transportation: Introduction to Transportation Engineering; Traffic and Road Safety: Types and Characteristics of Various Modes of Transportation; Various Road Traffic Signs, Causes of Accidents and Road Safety Measures.
Chapter 6
Environmental Engineering: Environmental Pollution, Environmental Acts and Regulations, Functional Concepts of Ecology, Basics of Species, Biodiversity, Ecosystem, Hydrological Cycle; Chemical Cycles: Carbon, Nitrogen & Phosphorus; Energy Flow in Ecosystems.
Water Pollution: Water Quality standards, Introduction to Treatment & Disposal of Waste Water. Reuse and Saving of Water, Rain Water Harvesting. Solid Waste Management: Classification of Solid Waste, Collection, Transportation and Disposal of Solid. Recycling of Solid Waste: Energy Recovery, Sanitary Landfill, On-Site Sanitation. Air & Noise Pollution: Primary and Secondary air pollutants, Harmful effects of Air Pollution, Control of Air Pollution. . Noise Pollution Harmful Effects of noise pollution, control of noise pollution, Global warming & Climate Change, Ozone depletion, Greenhouse effect
Text Books:
1. Palancharmy, Basic Civil Engineering, McGraw Hill publishers.
2. Satheesh Gopi, Basic Civil Engineering, Pearson Publishers.
3. Ketki Rangwala Dalal, Essentials of Civil Engineering, Charotar Publishing House.
4. BCP, Surveying volume 1
This presentation includes basic of PCOS their pathology and treatment and also Ayurveda correlation of PCOS and Ayurvedic line of treatment mentioned in classics.
How to Make a Field Mandatory in Odoo 17Celine George
In Odoo, making a field required can be done through both Python code and XML views. When you set the required attribute to True in Python code, it makes the field required across all views where it's used. Conversely, when you set the required attribute in XML views, it makes the field required only in the context of that particular view.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
This presentation was provided by Steph Pollock of The American Psychological Association’s Journals Program, and Damita Snow, of The American Society of Civil Engineers (ASCE), for the initial session of NISO's 2024 Training Series "DEIA in the Scholarly Landscape." Session One: 'Setting Expectations: a DEIA Primer,' was held June 6, 2024.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UP
Murach: How to transfer data from controllers
1. How to transfer data from
controllers
By : Eng. Mahmoud Hassouna
Email : M.hassuna2@gmail.com
2. Now, this chapter presents more details about how that
works. In addition, it presents several new ways to transfer
data from a controller to a view or to another controller.
3. How to use ActionResult objects
The apps you’ve seen so far in this book have transferred data from a
controller to a view by passing a model object to the View() method.
This method returns a ViewResult object, which is a subtype of the
ActionResult class. Now, this chapter presents more details about how
you can use the ActionResult class to transfer data from a controller to
a view.
4. An introduction to ActionResult subtypes
The ActionResult type provides information to MVC about the type
of HTTP response an action method should return. The response can
be content, like HTML or JSON, or it can be an HTTP status code such
as 404 Not Found.
5. The ActionResult hierarchy:
Figure 8-1 begins by presenting the hierarchy of the
ActionResult class. Here, the abstract ActionResult class
implements the IActionResult interface. Then, several subtypes
inherit and extend the ActionResult class. The table in this
figure lists some of the most common subtypes of the
ActionResult type. Each subtype has a specific purpose. For
instance, the ViewResult class renders a view and sends the
resulting HTML to the browser. The JsonResult class sends JSON
to the browser. The FileResult class sends a file to the browser.
The RedirectToActionResult class uses HTTP to instruct the
browser to redirect to a URL that corresponds to the specified
action method. And so on.
6. Common ActionResult subtypes:
Class Description
ViewResult
RedirectResult
RedirectToActionResult
JsonResult
FileResult
StatusCodeResult
ContentResult
EmptyResult
Renders a specified view as HTML and sends it to the browser
Performs an HTTP redirection to the specified URL
Performs an HTTP redirection to a URL that’s created by the routing system
using specified controller and action data
Serializes an object to JSON and sends the JSON to the browser
Returns a file to the browser
Sends an HTTP response with a status code to the browser
Returns plain text to the browser
Returns an empty response to the browser
7. A URL that provides a full list of the ActionResult subtypes
https://docs.microsoft.com/en-us/dotnet/api/
microsoft.aspnetcore.mvc.actionresult
Description
• Within a controller, an action method can return any type of
ActionResult object. The ActionResult class is an abstract class that
implements the IActionResult interface.
• Since the ActionResult class has many subtypes, an action method
can return many different types of result objects
8. How to return ActionResult objects
The ActionResult object returned by an action method tells MVC the type of
response that should be sent to the browser.
The names of these methods correspond to the ActionResult subtype they
return. For instance, the View() method creates a ViewResult object, the
RedirectToAction() method creates a RedirectToActionResult object, and so on.
Some methods of the Controller class that return an
ActionResult object :
Method Creates
View()
Redirect()
RedirectToAction()
File()
Json()
ViewResult object
RedirectResult object
RedirectToActionResult object
FileResult object
JsonResult object
9. 1- The first overload accepts no arguments and renders the default view for
the current controller and action method. For instance, if an Index()
method in the Home controller calls the View() method with no arguments,
MVC renders the HTML for the Home/Index view.
Some of the overloads of the View() method:
Method Description
View()
View(model)
View(name)
View(name, model)
Renders the default view for that controller and action method.
Transfers a model object to the default view and renders that view.
Renders the specified view. This method starts by searching for the
specified view in the view folder for the current controller. Then, it
searches in the Views/Shared folder.
Transfers a model object to the specified view and renders that view.
10. 2- The second overload accepts a model object that’s used by the
default view. For instance, if an Index() action method in the Home
controller passes an object to the View() method, MVC transfers that
object to the Home/Index view. Then, the view uses that object to render
its HTML
3- The third overload accepts a string that tells MVC which view file to use.
MVC starts by looking for this file in the folder for the current controller.
Then, it looks in the Shared folder. For instance, if an Index() action
method in the Home controller passes the string “Error” to the View()
method, MVC looks for the Error.cshtml file in the Views/Home folder. Then,
it looks in the Views/ Shared folder.
4- The fourth overload accepts a string and a model object. Thus, if an
Index() action method in the Movie controller passes the string “Edit” to
the View() method, MVC passes the specified model object to the
Edit.cshtml file in the Views/Movie folder.
11. An action method that returns a ViewResult object:
public ViewResult List() {
var names = new List { "Grace", "Ada", "Charles" };
return View(names);
}
An action method that returns a RedirectToActionResult object:
public RedirectToActionResult Index() => RedirectToAction("List");
An action method that may return different types of result objects:
[HttpPost]
public IActionResult Edit(string id) {
if (ModelState.IsValid)
return RedirectToAction("List");
else
return View((object)id); // cast string model to object
}
12. Description:
• The Controller class provides several methods that create objects of
ActionResult subtypes. Most of these methods include several overloads
that allow you to customize the ActionResult object that’s created.
• When Visual Studio generates action methods, it uses IActionResult as
the return type.
• If an action method only returns one type of ActionResult object, it’s a good
practice to specify that subtype as the return type.
• If an action method may return multiple types of ActionResult objects, you
can specify the ActionResult abstract class or the IActionResult interface
as the return type.
• If you want to use a string as a model, you must cast it to an object first.
13. How to use the ViewData
and ViewBag properties
Up until now, you’ve seen how to use the ViewBag property of the
Controller class to transfer data from an action method to a view. In a
moment, this chapter will review the ViewBag property and explain it in
more detail. But first, it shows how to use the closely-related ViewData
property of the Controller class, which also lets you transfer data to a
view.
14. The ViewData property of the Controller class has a data type of
ViewDataDictionary. This means that the property is a collection of
key/value pairs. For this dictionary type, the key is a string and the value is
an object
The ViewData property is shared with the associated view, including the
view’s layout. As a result, any data stored in the ViewData dictionary is
available to the view and its layout.
The ViewDataDictionary class also has some properties that a view can
use. The table in this figure summarizes some of these properties. Then, the
second code example shows how a view can use these properties to
display the data in the ViewData dictionary to the user. To do that, the
code uses the Count property to display the number of items, and it uses
a KeyValuePair object to get each item and display its key and value.
15. If you just want to display a ViewData value in the browser, you don’t need
to do anything special to it. That’s because Razor automatically calls the
ToString() method of an object in the dictionary. However, if you want to
work with a value in the ViewData dictionary in code, you must first cast it to
the appropriate data type. For instance, the third code example gets the
value for the Price item, casts it to the double type, and then uses the
ToString() method to apply currency formatting to the double value.
However, before you call a method from a value, you should check to make
sure the value isn’t null. Otherwise, your app might throw exceptions. For
instance, the fourth code example shows how to check if the Price value is
null. If it is, the code sets the value to an empty string. Otherwise, it casts the
value to a double type and applies currency formatting. Since this value is of
the non-nullable double type, this code uses the conditional operator (? :) to
perform this check
16. Controller code that adds two items to the ViewData property
public ViewResult Index() {
ViewData["Book"] = "Alice in Wonderland";
ViewData["Price"] = 9.99;
return View();
}
17. Some of the properties of the ViewDataDictionary class
Property Description
Count
Keys
Values
Returns the number of key/value pairs in the dictionary.
Returns a collection of strings containing the keys in the dictionary
Returns a collection of objects containing the values in the dictionary.
18. Razor code that displays all the items in the ViewData object
<h2> @ViewData.Count items in ViewData</h2>
@foreach (KeyValuePair item in ViewData) {
<div> @item.Key - @item.Value </div>
}
The view in the browser
19. Razor code that casts a ViewData object to the double type
<h4>Price: @(((double)ViewData["Price"]).ToString("c")) </h4>
The view in the browser
Razor code that checks ViewData values for null
Non-nullable type (double)
<h4> Price: @((ViewData["Price"] == null) ? "" :
((double)ViewData["Price"]).ToString("c")) </h4>
Nullable type (string)
<h4> Book: @ViewData["Book"]?.ToString() </h4>
20. Description :
The Controller class has a ViewData property that lets you transfer data
to a view.
The ViewData property is of the ViewDataDictionary type, which is a
collection of key/value pairs where the key is a string and the value is an
object.
When you display a ViewData value in a view, Razor automatically calls
the object’s ToString() method.
If you want to work with a ViewData value in code, you must cast the
value to its data type. But first, you should check to make sure the value
isn’t null
21. How the teams of the National Football League (NFL) are organized
There are two conferences, the NFC and the AFC.
Each conference contains four divisions named North, South, East, and West.
Each division contains four teams.
23. The NFL Teams app after a conference and division are selected
24. The Home controller
public class HomeController : Controller
{
private TeamContext context;
public HomeController(TeamContext ctx) {
context = ctx;
public ViewResult Index(string activeConf = "all“
, string activeDiv = "all")
{
// store selected conference and division IDs in view bag ViewBag.ActiveConf = activeConf;
ViewBag.ActiveDiv = activeDiv;
// get list of conferences and divisions from database
List <conferences >= context.Conferences.ToList();
List <divisions> = context.Divisions.ToList();
// insert default "All" value at front of each list
conferences.Insert(0, new Conference { ConferenceID = "all“
, Name = "All" });
divisions.Insert(0, new Division { DivisionID = "all",
Name = "All" });
25. // store lists in view bag
ViewBag.Conferences = conferences;
ViewBag.Divisions = divisions;
// get teams - filter by conference and division
IQueryable query = context.Teams;
if (activeConf != "all")
query = query.Where(
t => t.Conference.ConferenceID.ToLower() ==
activeConf.ToLower());
if (activeDiv != "all")
query = query.Where(
t => t.Division.DivisionID.ToLower() ==
activeDiv.ToLower());
// pass teams to view as model
var teams = query.ToList();
return View(teams);
}
}
26. The custom route in the Startup.cs file
endpoints.MapControllerRoute(
name: "custom",
pattern: "{controller}/{action}/conf/{activeConf}/div/{activeDiv}");
endpoints.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
31. How to work with view models
The applications you’ve seen so far have used the View() method to
transfer a single entity object or a collection of entity objects to a view.
Sometimes, however, the data needed by a view doesn’t match the data
in an entity model.
For example, the model object for the Index view of the NFL Teams app is a
collection of Team objects. However, that view also needs a collection of
Conference objects and a collection of Division objects to build the links to
filter by conference and division. In addition, it needs the IDs of the active
conference and division.
32. How to create a view model
Typically, view models are lightweight classes that contain only data.
However, they can also contain simple helper methods for the view. For
instance, the TeamListViewModel class provide two methods named
CheckActiveConf() and CheckActiveDiv() that the view can use to
determine the active link in the conference and division sections. That’s
acceptable because this logic only impacts how the view is displayed.
However, a view model shouldn’t have logic that impacts other parts of
the app such as the entity model or controller
34. Description:
A view model is a regular C# class that defines a model of the data
that’s needed by a view.
By convention, the name of a view model class ends with a suffix of
“ViewModel”, but this isn’t required.
Most view models only provide data. However, a view model can
also contain simple methods that help the view display that data
35. Two of the HTTP status codes for redirection
The ActionResult subtypes for redirection
Code Description
302 Found
301 Moved Permanently
Directs the browser to make a GET request to another URL.
Directs the browser to make a GET request to another URL for
this and all future requests.
Subtype 302 Found method 301 Moved Permanently
method
RedirectResult
LocalRedirectResult
RedirectToActionResult
RedirectToRouteResult
Redirect()
LocalRedirect()
RedirectToAction()
RedirectToRoute()
RedirectPermanent()
LocalRedirectPermanent()
RedirectToActionPermanent()
RedirectToRoutePermanent()
36. How to know which subtype to use for redirection
Some of the overloads available for the RedirectToAction() method
Subtype Use when…
RedirectResult
LocalRedirectResult
RedirectToActionResult
RedirectToRouteResult
Redirecting to an external URL, such as https://google.com.
Making sure you redirect to a URL within the current app.
Redirecting to an action method within the current app.
Redirecting within the current app by using a named route.
Arguments Redirect to…
(a)
(a, c)
(a, routes)
(a, c, routes)
The specified action method in the current controller.
The specified action method in the specified controller.
The specified action method in the current controller with route parameters.
The specified action method in the specified controller with route parameters.
37. Code that redirects to another action method
Redirect to the List() action method in the current controller
public RedirectToActionResult Index() => RedirectToAction("List");
Redirect to the List() action method in the Team controller
public RedirectToActionResult Index() => RedirectToAction("List", "Team");
Redirect to the Details() action method in the current controller with a parameter
public RedirectToActionResult Index(string id) =>
RedirectToAction("Details", new { ID = id });
Use a shortcut when variable name and route segment name match
public RedirectToActionResult Index(string id) =>
RedirectToAction("Details", new { id });
Use a string-string dictionary to supply a parameter
public RedirectToActionResult Index(string id) =>
RedirectToAction("Details",
new Dictionary<string, string>(){ { "ID", id } } );
38. A browser message that’s displayed when you refresh a page
that’s displayed by a POST request
Two action methods that uses the Post-Redirect-Get (PRG) pattern
A Delete() action method for a POST request
39. Description
To prevent resubmission of POST data, you can use the PostRedirect-Get (PRG)
pattern. With this pattern, a POST action writes data to the server and then
redirects to a GET action to read data from the server.
How to use the TempData property
So far, this chapter has shown how to transfer data from a controller to a
view. Sometimes, though, you need to transfer data from a controller to another
controller. To do that, you can use the built-in TempData property that’s available
from controllers and views.
40. An action method that uses TempData with the Post-
Redirect-Get pattern
42. Description
The Controller class has a property named TempData that lets you transfer data to another
controller or view.
Data in TempData persists across multiple requests until it is read. By contrast, data in ViewData
and ViewBag only persists until the end of the current request.
TempData is often used with the PRG pattern because that pattern takes place across two
requests (the POST request and the subsequent GET request).
TempData can only store data that can be serialized such as primitive types.
Because TempData is a dictionary, it has normal dictionary properties like Keys and Values, which
in turn have a Contains() method you can use to check for values.
By default, ASP.NET Core 3.0 and later automatically enable TempData when you call the
AddControllersWithViews() method in the Configure() method of the
Startup.cs file.
43. Two methods of the TempDataDictionary class
Method Description
Keep()
Keep(key)
Peek(key)
Marks all the values in the dictionary as unread, even if they’ve already been
read.
Marks the value associated with the specified key as unread, even if it has already
been read.
Reads the value associated with the specified key but does not mark it as read
45. When to use the Keep() and Peek() methods
Use Peek() when you know you want the value to stay marked as unread.
Use a normal read and Keep() when you want to use a condition to determine
whether to mark the value as unread
46. The Home page after selecting a conference and division
The Details page after clicking on a team
48. Description
This version of the NFL Teams app uses two view models named TeamViewModel
and TeamListViewModel.
The TeamListViewModel inherits the TeamViewModel. That way, the ActiveConf
and ActiveDiv properties are only coded in the TeamViewModel class.
Since the overloaded Details() action method uses the PRG pattern, it uses the
TempData dictionary to transfer data from the action method that handles POST
requests to the action method that handles GET requests.
50. Description
The Home/Index view receives a TeamListViewModel object from the Index()
action method of the Home controller.
The <form> element for each team binds three hidden fields to the ActiveConf,
ActiveDiv, and Team.TeamID properties of the view model
51. Terms
dynamic type
alias
view model
idempotent
Post-Redirect-Get (PRG) pattern
open redirection attack
52. Summary
ViewBag properties use C#’s dynamic type. As a result, the data type of
each property is set at runtime.
Under the hood, the ViewBag property uses the ViewData dictionary
to store its dynamic properties. Thus, you can think of the ViewBag
property as an alias for the ViewData dictionary.
A view model is a regular C# class that defines a model of the data that’s
needed by a view.
An idempotent request has the same effect on the server whether it’s
made once or multiple times.
To prevent resubmission of POST data, you can use the
Post-Redirect-Get (PRG) pattern. With this pattern, a POST action
writes data to the server and then redirects to a GET action to read data
from the server.
Open redirection attacks attempt to redirect to a malicious external site.