Hi fellow devs, i'm rebuilding some projects, so i could use a little help.
My previous solution was a .Net framework app that uses a lot of APIs from a webapi project. I'm moving to .Net core and a little confused about the performance and sustainability. Should i stick to mvc or the Razor pages approach could be better?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (4)
Just adding my thoughts to any other suggestions...
I personally use Controllers for Web API, and I use MVC for none Web API content because I prefer to control all through the Controllers, which are very thin, as the business logic is mostly in the Services in my case, which are injected to the Controllers, and some services are re-used with Web API Controllers.
The reason I prefer controllers is that I would like to see in a glance what is going into my Views from one place, instead of clicking on every single Razor page and seeing what is happening there. That is my preference.
If you haven't done too much work with ASP.NET Core, make sure you are using/utilising DI (Dependency Injection) regardless if you use MVC or Razor pages.
I do use also Razor pages mainly for static content. I also combine MVC + Razor pages.
You can also use Blazor with your MVC and Razor pages. I am slowly moving from Angular to Blazor so I don't have to deal with JavaScript. Some parts of your Views can use Blazor components, if it is appropriate for your solution. Again, depending on your project, there is a huge time saving if you use Blazor instead of JavaScript frameworks.
I would recommend to use Blazor in some cases, so you/team can test and see if there are any benefits of it to use it in some parts. Also, you can combine Blazor:
If needed you can also combine Blazor with JavaScript together (communicate both ways) but I personally avoid it as I would like to stick with one or the other.
Regarding the performance, there are many tests out there which measure ASP.NET Core as very efficient, because .NET 3.1+ are performance optimised like .NET Framework is not. There are many Microsoft blog posts about that, addressing memory optimisation and many benchmark tests showing what is faster in .NET Core..
Obviously, you would test your performance in case your architecture/project has something built in which wouldn't take advantage of .NET Core.
Thanks for the advice. I'm moving to .net core after 6 years of .net framework so that's a lot of change to me. Just to make it more clear my projects, i have a static web app that recieve data to make a purchase. The webapi is responsable for doing all the work here, since the validation, persist in database and serving the html with the template. My razor pages app would have only two jobs, nav the user through pages and send the form to the external service. I'm using signoz to measure the diference since i still have the .net framework solution on.
It seems like Razor pages might be a good choice here 😊.
Here you are also some good articles to read:
devblogs.microsoft.com/dotnet/incr...
devblogs.microsoft.com/dotnet/intr...
docs.microsoft.com/en-us/aspnet/co...
Long time without using C# or .Net but I stick here just out of curiosity about this discussion 😁