how does visual studio determine which is a view vs a partial view? Another question would be; is there a way to convert my views into partial views?
Asked
Active
Viewed 7,605 times
2 Answers
21
In Razor there is no distinction between views and partial views as there is in WebForms (.aspx vs .ascx). In Razor all views are templates. Those templates could have a Layout:
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
In this case they are views. If there is no layout specified they could be considered as partial views. The Layout is usually defined in the ~/Views/_ViewStart.cshtml
file.
This being said if from your controller action you return PartialView();
instead of return View();
this layout will not be applied.
I would recommend you reading the following blog post about Razor views and layouts.

Darin Dimitrov
- 1,023,142
- 271
- 3,287
- 2,928
-
thank you. Glad I asked. Wow, this was an easy switch. just changed my controller and it is working. thanks a lot. – frank Jul 21 '11 at 22:58
-
@frank, so if this post helped you solve the problem you were having you may consider [marking it as answer](http://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) by clicking on the tick next to it. – Darin Dimitrov Jul 21 '11 at 23:00
-
Just to be clear to those searching and ending up here, there is a distinction though in processing - viewstart support, layout support (as you mentioned), etc http://completedevelopment.blogspot.com/2014/01/is-there-really-no-difference-between.html – Adam Tuliper Jan 12 '14 at 07:31
-
Nice.. clean and simple explanation. – NightKnight Apr 23 '14 at 05:46
3
Visual Studio doesn't determine which is a view and which is a partial view. You do. You tell MVC to render a partial view, and it renders whatever you give it.

Erik Funkenbusch
- 92,674
- 28
- 195
- 291