Alex K
Alex K

Reputation: 5212

Is it possible to use MVC without Asp.net pages?

I know that MVC is a design pattern that separates Model, View, Controller. Model - Logic View - Client View Controller - connection between the two.

In case I want to change one of this things it will be easy just to change view\Model and the controller.

So is it possible to use only WebApi and MVC without Aps.Net pages (cshtml files)?

Upvotes: 0

Views: 758

Answers (2)

komsky
komsky

Reputation: 1588

In short: yes, you can.

To elaborate: not sure what you mean, as .cshtml files are essentially the view part of MVC (the V part). ASP.NET MVC controllers by default return content of the .cshtml file by calling View() helper method.

But you can for example render html for the client inside your custom controller class without calling for a static html content. Or you might create WEB API project, with routing, models, and controllers, but no views - just plain data returned to the client.

Upvotes: 0

Robert Sandu
Robert Sandu

Reputation: 673

You can return html files

return new FilePathResult("path/FileName.html", "text/html");

And .cshtml files are Razor View Engine files, not Asp.Net pages. You can alson change the view engine, see here for a list of .net view egines.

Upvotes: 1

Related Questions