Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why Views and partial views have the same cshtml file extension in Razor?

I'm learning some basic stuffs in razor. I'm a little confused about the extension file: views and partial views seem to share the same extension cshtml. I thought that was a mistake on my behalf, but I've re-checked the checkbox, I get the same extension for both types of files.

Besides, with webform view engine, it's easier to locate views by their colors or/and extensions (View are white-.aspx, Partial are yellow-.ascx, Master are white/blue-.master)

If that's the way it has to be now, why would views and partial views share the same extension? Is there any reason they made them all have the same extension?

Thanks for helping

like image 576
Richard77 Avatar asked Dec 11 '10 01:12

Richard77


1 Answers

Razor views and partial views don't need a seperate file extension because both use the same base class.

In contrast, WebForms (ASPX) pages, user controls, and master pages all derive from different base classes which is why the distinction was necessary. It's simply a result of design decisions made during the creation of Asp.Net WebForms.

like image 112
marcind Avatar answered Oct 07 '22 23:10

marcind