Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use ASP.NET Core without MVC

Tags:

asp.net-core

I wonder if it is possible to use the new ASP.NET Core Framework without MVC Core. Are there any examples on how to achieve a small web page without integrating the whole MVC Framework? Serving simple routed razor pages?

like image 650
DoubleVoid Avatar asked Nov 01 '16 10:11

DoubleVoid


2 Answers

You can use MVC Core for REST API only (without using razor views, or for using your own template engine) by referencing only 'Microsoft.AspNetCore.Mvc.Core' package.

If you don't need MVC Core at all, just use '.NET Core Console Application' project template.

Regarding 'old aspx pages' without MVC pattern (from your comment): in current MVC Core version you cannot use razor views without controller; according to ASP.NET Core roadmap, this feature is planned for future 1.2 release.

like image 193
Vitaliy Fedorchenko Avatar answered Sep 28 '22 21:09

Vitaliy Fedorchenko


Yes, you can use Razor pages instead of a complete MVC project.

This Microsoft introduction explains how to use Razor pages and its most important features without the whole MVC framework.

This page uses the following sentences to decribe Razor pages:

As part of the release of .NET Core 2.0, there are also some updates to ASP.NET. One of those is the addition of a new web framework for creating a “page” without the full complexity of ASP.NET MVC. New Razor Pages are a slimmer version of the MVC framework and in some ways an evolution of the old “.aspx” WebForms.

like image 28
Markus Weninger Avatar answered Sep 28 '22 20:09

Markus Weninger