NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

ASP.NET MVC:

MVC patrern -
The Model represents the application core (for instance a list of database records).
The View displays the data (the database records).
The Controller handles the input (to the database records).

Avantaje MVC -
Separation of Concerns
More control over HTML, JavaScript, and CSS
Testability

MVC application life cycle -
Creating the request object:
1. Fill Route
2. Fetch Route
3. Request context created
4. Controller instance created
Creating a Response object : ViewRestult, JSON, PartialView, etc

MVC Filters:
Filters are used to perform actions before or after the operations of the controller.
There are 4 types of filters:

Action filters - Action filter executes before and after an action method executes
Authorization Filters - Authorization filters are used to implement authentication and authorization for controller actions.
Result Filters
Exception Filters

Routing in MVC:
In other ways let us say routing help you to define a URL structure and map the URL with a controller.
1) From RouteConfig.cs with the MapRoute method. You need to specify a name, a url(controller name, action name, and parameters) and a default value.
2) Route attribute in the action method of the controller.

Temp data, View, and View Bag:
In ASP.NET MVC there are three ways to pass data between the controllers and views:

ViewData is nothing but a dictionary of objects and it is accessible by string as key. (ViewData["Student"])
ViewBag is able to set and get value dynamically and able to add any number of additional fields without converting it to strongly typed (ViewBag.Student = Student)
TempData is stored data just like live session for short time. (TempData["Student"] = Student;)

MVC Partial Views:
Partial view is a reusable view which can be embedded inside another view.

View vs PartialView:
View contains the layout page
Partial view is designed specially to render within the view and just because of that it does not consist any mark up.
The view is not lightweight as compare to Partial View.

ActionResults:

-View (View result is a basic view result. It returns basic results to view page)
-Partial View (Partial View Result is returning the result to Partial view page.) PartialView("_PartialView");
-Redirect (Redirect result is returning the result to specific URL) Redirect("Home/Contact");
-Redirect To Action (Redirect to Action result is returning the result to a specified controller and action method. ) RedirectToAction("Login", "Account");
-Redirect To Route ()
-Json ( It will return simple text file format and key value pairs)
-File (File Result returns different file format view page when we implement file download concept in MVC using file result)
-Content (MVC returns different format using content return like HTML format, Java Script format and any other format.) Content("<script>alert('Welcome To All');</script>");

HTML helpers:
A HTML helper is a special type of method used to render HTML content in a view. HtmlHelper class generates html elements using the model class object in razor view. (@Html.ActionLink("Create New", "Create"))
The difference between calling the HtmlHelper methods and using an html tags is that the HtmlHelper method is designed to make it easy to bind to view data or model data.

MVC Razor Syntax:
Razor is a markup syntax that lets you embed server-based code (C#) into web pages.
Razor code blocks are enclosed in @{ ... }. Code statements end with semicolon;
Variables are declared with the var keyword

Output Caching in MVC:
The main purpose of using Output Caching is to dramatically improve the performance of an ASP.NET MVC Application. It enables us to cache the content returned by any controller method so that the same content does not need to be generated each time the same controller method is invoked

Bundling and Minification in MVC:
Bundling - It lets us combine multiple JavaScript (.js) files or multiple cascading style sheet (.css) files so that they can be downloaded as a unit, rather than making individual HTTP requests.
Minification - It squeezes out whitespace and performs other types of compression to make the downloaded files as small as possible.

Validation Summary in MVC:
The ValidationSummary helper method generates an unordered list (ul element) of validation messages. In the model =>
[Required(ErrorMessage="CustomerName is mandatory")],
[Range(1000,10000,ErrorMessage="Range should be between 1k & 10k")], etc..

Handling errors in MVC:
Global Error Page in Web.Config file-
<customErrors mode="On" defaultRedirect="~/ErrorHandler/Index">
<error statusCode="404" redirect="~/ErrorHandler/NotFound"/>
</customErrors>
HandlerErrorAttribute- For example, if you wanted to show a particular MVC view when a SqlException happens, you can do it with the code below:
[HandleError(ExceptionType = typeof(SqlException), View = "SqlExceptionView")]
public string GetClientInfo(string username){....}

_Viewstart Page in ASP.NET MVC:
Instead of declaring the Layout page in every view page, we can use the _ViewStart page. Is a special view page containing the statement declaration to include the Layout page.

EF Code first:
1. Create the Model classes (If a navigation property can hold multiple entities (as in many-to-many or one-to-many relationships), its type must be a list in which entries can be added, deleted, and updated, such as ICollection) (By default, Entity Framework interprets a property that's named ID or classname ID as the primary key.)
2. Create the database context(DBContext) (public DbSet<Student> Students { get; set; })
3. Specify the connection string ( in Web.config )
4. To update databases you need NuGet -> Enable-Migrations, Add-Migration, Update-Database

EF Database first:
1. Create the database (Right click on Data Connections -> Add Connection…)(Connect to either LocalDB or SQL Express)
2. Reverse Engineer Model (Project -> Add New Item…, Select Data from the left menu and then ADO.NET Entity Data Model, Enter BloggingModel as the name and click OK, This launches the Entity Data Model Wizard, Select Generate from Database and click Next)

Proiecte MVC:
Internship => O platforma mica de Ecommerce
Functionalitati: Unit testing, Navigation bar, Cart(cu session. cart controller)


Licenta FitLifestyle =>
Functionalitati: Login Admin, Login Client(am folosit sesiuni), Search/Sortare de retete (filtrare cu .Where()), Detalii la fiecare reteta cu imagine(byte), pasi, ingrediente. Poti adauga ingrediente si se schimba valorile nutritionale. (JS getElementByClassName la calorii, pro, carb, etc)


MusicStore Microsoft =>
Functionalitati: Poti cauta albume dupa genul de muzica preferat (Artist, Album, Genre models)
Poti adauga un album in cosul de cuparaturi si il poti sterge din cos oricand. (Creezi un model de Cart.cs - aici pui id la album, numele, numarul de albume, Order.cs - aici pui toate detaliile cumparaturii, il faci sa mearga cu sesiuni)
Dupa comanda primesc un scurt mesaj de confirmare pe site.

Medii de Programare si dezvoltare (site studenti) =>
Functionalitati: CRUD basic pe 2 tabele. (Studenti, Cursuri, Inrolari-tabela de relatie). Validare la introducere de date(Client side si Server side)
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.