Razor glance versus partial view

How does a visual studio determine what a view or partial view is? Another question: is there a way to convert my views into partial views?

+8
asp.net-mvc razor asp.net-mvc-partialview
source share
2 answers

In Razor, there is no difference between views and partial views, as in WebForms (.aspx vs .ascx). In Razor, all views are templates. These templates may have a layout:

@{ Layout = "~/Views/Shared/_Layout.cshtml"; } 

In this case, they are representations. If the layout is not specified, they can be considered as partial views. The layout is usually defined in the file ~/Views/_ViewStart.cshtml .

This is said if from your action with the controller you return PartialView(); instead of return View(); this layout will not apply.

I would recommend you read the following blog post about Razor views and layouts.

+21
source share

Visual Studio does not define what a view is and is a partial view. You do. You specify the MVC for partial viewing, and it displays everything you give it.

+3
source share

All Articles