Sunday, May 22, 2022

What is Bundling and Minification in MVC?

 Bundling and minification are two new techniques introduced to improve request load time. It improves load time by reducing the number of requests to the server and reducing the size of requested assets (such as CSS and JavaScript).


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. At runtime, the process identifies the user agent, for example IE, Mozilla, etc. and then removes whatever is specific to Mozilla when the request comes from IE.

What is ViewStart?

 Razor View Engine introduced a new layout named _ViewStart which is applied on all view automatically. Razor View Engine firstly executes the _ViewStart and then start rendering the other view and merges them.


@ {

    Layout = "~/Views/Shared/_v1.cshtml";

}

< !DOCTYPE html >

    < html >

    < head >

    < meta name = "viewport"

content = "width=device-width" / >

    < title > ViewStart < /title> < /head> < body >

    < /body>

< /html>

Tuesday, May 3, 2022

WHAT ARE PARTIAL VIEWS IN ASP.NET MVC

 Partial View is a subpage of Main View page that keeps reusable parts of web pages. If your Main Page is too large then you can divide it into several pieces and store content into a partial page with a logical name. After that, you can call this partial page inside your main view page.


More Facts about Partial Page:

1. It is an effective way to breaking up large view pages into smaller components.

2. A partial page is reusable so keep common content in the partial page and used wherever you want.

3. You can recall partial page inside a view page using following ways:


@Html.Partial("ViewName")

// A view with this name must be in the same folder
@Html.Partial("ViewName.cshtml")

// Locate the view based on the application root
// Paths that start with ".php" or "~.php" refer to the application root
@Html.Partial("~/Views/Folder/ViewName.cshtml")
@Html.Partial("/Views/Folder/ViewName.cshtml")

// Locate the view using relative paths
@Html.Partial("../Account/LoginPartial.cshtml")
Use below link for more info
https://www.completecsharptutorial.com/asp-net-mvc5/adding-partial-views-pages-in-mvc-5-with-example.php