I have been given a sample MVC project that contains views with extension .aspx however when I create a new MVC project using the VS2013 ASP.Net wizard the views have extension .cshtml Are there 2 kinds of MVC project?
-
1These relate to the view engine (ASPX or Razor) used for generating the html markup in your views. [Refer this article](http://www.codeproject.com/Articles/534970/ASP-NET-MVC-Part-Razor-ASPX-View-Engine) for a detailed explanation – Jul 18 '15 at 02:57
2 Answers
Views
in MVC refer to either .cshtml
files in C# or .vbhtml
files in Visual Basic.
.aspx
files are webform
files and are not views-- this was the initial approach ASP.NET took to make webform development more similar to desktop application development. These pages are generally included in the route list as actual files, whereas MVC uses controller routes that aren't based on existing files (i.e., the url path doesn't match the file and directory structure like traditional html does), which ultimately serve the views. .aspx
files can also have code-behind
files to separate the html/aspx markup from the .NET code; those files will have either a .aspx.cs
or .aspx.vb
extension on them. In an MVC app, these files are also likely to have designer files.
One set of files for an aspx
file named MyPage
may have the following files:
- MyPage.aspx
- MyPage.aspx.cs or MyPage.aspx.vb
- MyPage.aspx.designer.cs or MyPage.aspx.designer.vb
The files in #3 may be hidden until you select 'show all files' in the project, or may not exist at all in a traditional 'web site' project type. I think you have to upgrade to a 'web application project (Wap)' project type before you can integrate MVC, though I may be wrong. All WAP projects should have these .aspx.designer.xx
files.

- 8,067
- 1
- 35
- 68
-
1I gave you an up vote because the answer has lots of good stuff. That said, I think this line might be false: ".aspx files are webform files and are not views." `System.Web.Mvc.WebFormViewEngine` lets us use them as views. No? – Shaun Luttin Jul 18 '15 at 03:37
-
@ShaunLuttin, I don't believe so, and I haven't used it. We generally remove that from the list of view engines to prevent unnecessary overhead. From what I read at the following link, the `RazorViewEngine` lets you use the Razor syntax with the `@`, etc. The `WebFormViewEngine` lets you use the webform syntax of `<%= %>` and `<% %>` that was traditionally used in the old `webforms` aspx code for binding to page members. http://www.c-sharpcorner.com/UploadFile/ff2f08/aspx-view-engine-vs-razor-view-engine/ – ps2goat Jul 18 '15 at 05:07
In MVC what extension should the view file names have?
.cshtml
unless you have a reason not to use the Razor view engine with C#.
Are there 2 kinds of MVC project?
The relevant answer is that there are many more than 2 different view engines. Razor was introduce in 2010. The Razor view engine is what comes out of the box in the Visual Studio MVC templates. See ASP.NET MVC View Engine Comparison for more info on more obscure view engines that work with ASP.NET MVC.

- 1
- 1

- 133,272
- 81
- 405
- 467