0% found this document useful (0 votes)
5 views

MVC Summary - Day 1

MVC (Model-View-Controller) is a design pattern that separates applications into Models, Views, and Controllers for better scalability and maintainability. The document also covers key concepts like class libraries, HTTP characteristics, status codes, and the implementation of MVC in ASP.NET MVC. It explains how each component functions and their roles in handling user requests and presenting data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

MVC Summary - Day 1

MVC (Model-View-Controller) is a design pattern that separates applications into Models, Views, and Controllers for better scalability and maintainability. The document also covers key concepts like class libraries, HTTP characteristics, status codes, and the implementation of MVC in ASP.NET MVC. It explains how each component functions and their roles in handling user requests and presenting data.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

MVC Summary - Day 1

MVC stands for Model-View-Controller, a design pattern that separates an


application into three main components: Models, Views, and Controllers. This
helps to achieve separation of concerns, scalability, maintainability, and
testability.

Models are responsible for data access and business rules. Views are
responsible for presenting the user interface, such as HTML pages or JSON
responses. Controllers are responsible for handling user requests, working
with the models, and selecting the views

A web page is identified by a URL, which is composed of different parts:


domain name, port number, internal path, and query string.
The URL http://www.test.com:1020/login?name=aly&age=30 can be
interpreted as follows: the web page or resource named login is located on
the web server www.test.com , which is listening on port 1020, and it
receives two parameters: name with the value aly, and age with the value 30

Class Library:

A class library is a reusable collection of code (classes, interfaces) without a


user interface. It is used to share common functionality across projects. It is
referenced by other projects and is not intended to function as a standalone
application.

Round Trip:

Complete request-response cycle between client (web browser) and server.


Key steps:
1. Client sends HTTP request (e.g., clicking a link).
2. Server receives request, processes it, generates response.
3. Server sends response back to client.
4. Client receives and displays response (e.g., webpage content).
SignalR:

It's a real-time communication library from Microsoft for bi-directional


connections. Used for chat applications, online multiplayer games
and notifications.
SignalR is one of the most popular Server-initiated communication
technologies. The Application Pushes updates to clients without requests.

HTTP Connection Characteristics:

1. Case Insensitivity:
HTTP response is case insensitive, which means that the names of the
headers and the values of some fields (such as methods and status codes)
are not affected by the letter case.
For example, Content-Type: text/html and content-type: TEXT/HTML are
equivalent.
2. Statelessness:
HTTP is stateless. This means that each request-response cycle is
independent and the server doesn't remember previous interactions with
the same client.
To maintain state information across requests, we need additional
mechanisms like:
Session Management: Stores user data on the server for a specific
duration.
Cookies: Stores small data pieces on the client's browser, accessible by
the server.
Hidden fields: Embed data in forms submitted to the server.

3. Connectionless:
HTTP connections are connectionless. This means that after a response is
sent, the connection is closed.
For subsequent requests, a new connection is established.
This is efficient for short-lived interactions, but persistent connections
(e.g., WebSockets) exist for longer-lasting communication.
This reduces the overhead of keeping the connection alive and allows the
server to handle more requests. However, this also increases the latency
and the network traffic for each request.
Status Codes:

Status code is a 3-digit number that indicates the result of the HTTP request.
The first digit defines the class of the response, and the last two digits are
specific to each status.

 100 Information: Indicate that the request was received and the
processing is continuing. For example, 100 Continue means that the client
should continue the request or ignore the response if the request is
already finished.

 200 OK: The request was successfully received, understood, and


accepted. For example, 200 OK means that the request succeeded and the
response contains the requested resource.
 300 Redirection: Further action is needed to complete the request. For
example, 300 Multiple Choices means that the server has several options
for the requested resource and the client can choose one of them

 400 Client Error: The request contains incorrect syntax or cannot be


fulfilled. For example, 404 Not Found means that the server could not find
the requested resource, and 401 Unauthorized means that the client needs
to provide authentication credentials to access the resource

 500 Server Error: Indicate that the server failed to fulfill a valid request.
For example, 500 Internal Server Error means that the server encountered
an unexpected condition that prevented it from completing the request.

The MVC Pattern in ASP.NET MVC

Model:
Represents data and business logic, often mapped to database entities. The
Model includes validation rules and view models for data presentation.
View:
Responsible for presenting data to the user. A View uses Razor syntax, a
combination of HTML and C#, to dynamically generate HTML content.
Different views exist for various actions (create, edit, show) within an entity.
The Razor engine converts views to HTML understandable by the browser.
Controller:
The "brain" of the application, handling user requests. The Controller receives
requests from the web server, interacts with the Model for data, and chooses
the appropriate View. It consists of C# classes with methods for different
actions.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy