Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] Razor vs MVC #1

Closed
ghost opened this issue Sep 4, 2019 · 1 comment
Closed

[QUESTION] Razor vs MVC #1

ghost opened this issue Sep 4, 2019 · 1 comment

Comments

@ghost
Copy link

ghost commented Sep 4, 2019

Hi @thewebchameleon,

May I ask why did you move from MVC controller style to Razor Pages.

Do you have any plans on creating the same project using MVC?

@ghost ghost closed this as completed Sep 5, 2019
@thewebchameleon
Copy link
Owner

thewebchameleon commented Sep 6, 2019

@ghost I was initially skeptical at first when Razor Pages came along; finding similarity with the old ASP.NET Web Forms but after further research and a few experiments I have come to realise its potential.

Razor Pages behind the scenes still uses MVC and you could very much mix and mash the 2 together. In my opinion, i think Razor Pages are more organised and are easier to develop (eg. anti-forgery tokens included by default). My big wins are having controller logic now sitting in the relevant page as well as the page having its own built-in viewmodel.

In this template project (MVC and Razor) I have extracted business logic into Services and Managers, thus making Controllers and Pages only handle request validation and response handling. In MVC, I thought this might alleviate the bloat often found in Controllers but instead only made them a list of similar methods all doing pretty much the same thing. Razor Pages doesn't solve the DRY problem but helps group purpose into smaller Controllers (Pages).

Controllers still have their uses though, functionality not grouped by a page (eg. Logging out) should reside in a Controller although I did end up duplicating some routing logic (BaseController.cs and BasePageModel.cs).

I recommend trying out Razor Pages, there is a good read here and a good discussion here detailing the differences.

At this moment I don't have any plans to continue updating Template.MVC but it is compatible with some tweaking should you wish to go the MVC route.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant