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

Why choose MVC tutorials over Razor Pages #6146

Open
Rick-Anderson opened this Issue Apr 30, 2018 · 216 comments

Comments

Projects
None yet
@Rick-Anderson
Contributor

Rick-Anderson commented Apr 30, 2018

This issue is for feedback of why you follow a ASP.NET Core MVC tutorial over the Razor Pages version.

Razor Pages vs MVC with controller and views - how do I decide #3889

@Rick-Anderson Rick-Anderson self-assigned this Apr 30, 2018

@Rick-Anderson Rick-Anderson added this to the Backlog milestone Apr 30, 2018

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Apr 30, 2018

Per @wcski
I have already done the Razor pages tutorial. I am doing the MVC tutorial because the projects I will be working on at work are MVC and not Razor pages.

@Staartvin

This comment has been minimized.

Staartvin commented May 2, 2018

I have never worked with ASP.net Core before, but I prefer to start with a design (MVC) I'm familiar with to get to know the fundamentals of C# and ASP.net before plunging in Razer.

@dmillzilla

This comment has been minimized.

dmillzilla commented May 4, 2018

I'm far more familiar with MVC. With that said, the instructions for the Razerpages are shown with Visual Studio for Windows. The tutorial that linked the razer instructions was a Visual Studio for Mac tutorial..

@kshorod

This comment has been minimized.

kshorod commented May 4, 2018

I have glanced over the razor pages tutorial. I think for beginners it is indeed better than the MVC one. However, as an experienced MVC developer and somebody who will have to help interns learn programming:

  1. Razor Pages is a spiritual successor (fairly or not) of Web Forms, which we moved over from to MVC and the skepticism towards anything resembling web forms is still there,
  2. Right now you kind of need to be able to develop both MVC5 and core, and there is no pages in MVC5,
  3. It is easier to move to developing APIs after doing stuff in MVC rather than pages,
  4. Myself having experience with MVC makes it that much easier to help teach it.

Overall, to me, Razor Pages is in a place where it is cool to know it, it may be cool to use it, but you absolutely need to know MVC anyway, so might as well start with that.

Keep up the good work!

@racouster

This comment has been minimized.

racouster commented May 5, 2018

The Razor Tutorial requires VS and I've only got VS Code installed right now. Also why do I need Razor pages I don't like papercuts. Also isn't it just more overhead if I'm using React or Angular or similar (I mean I know they're client side, but it's more bloat. Guess I should just use WebApi and react or whatever.

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented May 5, 2018

@racouster The VS Code

@meision

This comment has been minimized.

meision commented May 8, 2018

It was very pity for me that ASP.net core team introduced Razor page. As we know, Microsoft technology lost developer in last years. Why we introduce WF/WPF/WCF, and then tell that those technology out of date.
The WebForm, tell it was out, the "MVC is new thing", and currently, tell "MVC was out, Razor page is new thing", what about tomorrow? "Razor page is out, what is new thing?". The elder developers must continue study that "new" but not the key technology -- that is why a lot of .net developer transfer to Java, why not make some stable framework for developers?

secondary, we have a lot of optimizing or quickly developing framework on MVC framework, like ABP framework ect. If change to new razor page, the whole pattern should be refactored, that is sucks and waste a lot of resources.

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented May 10, 2018

Razor pages is not MVC, is a block, post page style, a moving back to old .aspx style, it is dead!
MVC is Clean, is freedom, is easy to do App and easy to do live controls and you can do page style also.
I hate Razor Pages, it is old style with new clothes!

@gyurisc

This comment has been minimized.

gyurisc commented May 11, 2018

MVC is a clean and proven paradigm. While Razor page approach feels like a step backward. I also feel that MVC plays better when you want to support mobile clients or Angular and React in your app. Razor pages does not seem to offer any of that.

Maybe it would help developers if there would be explanations when to use Razor Pages and when MVC is appropriate. My guess is that Razor Pages can be good for developing small one-off internal tools and sites inside the enterprise and MVC is better for public facing web sites.

@davidfowl

This comment has been minimized.

Member

davidfowl commented May 11, 2018

@JAugustoGuimaraes @gyurisc have you used Razor Pages?

@gyurisc

This comment has been minimized.

gyurisc commented May 11, 2018

@davidfowl I must confess I didnot worked with Razor Pages yet. I just skimmed through the tutorial. It is hard for me to see why this approach is better than MVC. Razor pages really reminds me the old ASP.NET Webform approach

@JAugustoGuimaraes

This comment has been minimized.

@rseyf

This comment has been minimized.

rseyf commented May 15, 2018

I'm developing web applications professionally for about 7 years and I had experience in Symfony and J2EE frameworks. there is an unwritten law about programming professional web applications, laws like tools you use for code editors, web servers , load balancers, in-memory storages, documentation ,and even in development methods such as standard design patterns (like abstract, DI , MVC, front controller...).

So , please note that if you want coders to move to Microsoft web development platforms , you have to offer more and respect the rules! we are developers, not users. You SHOULD NOT ignore standards for sake of ease of use. Razor IS NOT STANDARD in real-world developers world.
for example , some of developers common preferences are:

  • "Gnu/Linux" , "Unix", "Unix-likes" rather than "Microsoft Windows".
  • "Vim", "Sublime Text" ,"VS Code" or other code editors nor "Jetbrains IDEs" rather than "Visual Studio Enterprise" because of price and freedom.
  • "NGINX" or "APACHE" web servers rather than "IIS" or "Kestrel".
  • "MariaDB" / "MySQL" or "PostgreSQL" rather than "MS SQL".

That's why I personally prefer "MVC web app with Visual Studio Code on macOS or Linux" tutorial to others, because it makes sense as a standard way to do the job.

it's like users expectations in Microsoft Windows applications:

No windows user expects to see "Exit" option under the "Help" menu, they look for this option under the "File" menu!

Thank you for the docs!

@davidfowl

This comment has been minimized.

Member

davidfowl commented May 15, 2018

@rseyf have you given razor pages a try?

@rseyf

This comment has been minimized.

rseyf commented May 15, 2018

@davidfowl Yes of course I did, Razor is ASP.NET Core application plus extra configurations. My answer is about the documentation and what developers expected to read for the first topic.

I'm suggesting to start "Cross platform tutorials" section with "MVC web app with Visual Studio Code on macOS or Linux" instead of Razor pages.Because Razor pages are based on Visual Studio IDE and it's confusing to start with for other platforms developers.

screen shot 2018-05-15 at 07 35 08

Any Ideas?

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented May 15, 2018

.Because Razor pages are based on Visual Studio IDE and it's confusing to start with for other platforms developers.

That's not correct.

@rseyf

This comment has been minimized.

rseyf commented May 15, 2018

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented May 15, 2018

Follow the VS Code version
image

@rseyf

This comment has been minimized.

rseyf commented May 15, 2018

@Rick-Anderson , @davidfowl ,
I know that there is a VS Code tutorial for it, I have no problem with starting with MVC with vs code nor VS Enterprise, and I know the difference of VS code & Visual Studio IDE. That's not what I mean to say.

Imagine a person who is a Python and Django developer and wants to read about .Net Core MVC itself. (let's ignore Razor as a new term for him/her), documentation categories are so confusing and the first cross-platform tutorial starts with Visual Studio / Visual Studio Code . He/She cannot find any tutorials just about the framework itself. it's a really HUGE problem.

I'm trying to say it's COMPLETELY WRONG to create a web framework documentation on a special IDE or code editor specifications. it should start with an independent tutorial just about the MVC framework itself.

That's why I'm suggesting to change the order of the "cross platform topics" links to make it less confusing.

Can you find any IDE or Editor names in a documentation of other professional web frameworks?

???

@davidfowl

This comment has been minimized.

Member

davidfowl commented May 15, 2018

Unlike those frameworks, most of our frameworks have tooling that come with it. The moral equivalent to that is the CLI scaffolding that most of those frameworks offer.

Symphony has composer:

image

Spring has guides based on various package managers or IDE:

image

The java ecosystem is most similar to .NET which is why you see things that look similar.

So it's not odd to create a tutorial based on the tool and it's not uncommon to see that in other language ecosystems.

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented May 15, 2018

@davidfowl Ok, build tools for MVC!! ...Give to us the freedom!! I will never be locked with Microsoft way any more!

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented May 15, 2018

Why not the standard MVC? Microsoft don't like standards?
Please, tell me what is wrong with MVC!!?? You don't like controllers?? It's too hard??
Whats is the advantage of RazorPages (.aspx style) ? Show us a reason to change!!

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented May 16, 2018

Please, tell me what is wrong with MVC!!?? You don't like controllers?? It's too hard??
Nothing is wrong with MVC, it's all about what RP (Razor Pages) do better.

Whats is the advantage of RazorPages (.aspx style) ? Show us a reason to change!!
Having migrated MVC with EF Core to RP with EF I found many advantages:

No more passing data with messy ViewData. Use the build-it view model you get with PageModel.

No more weird overloads to disambiguate Get/Post methods

Razor pages give less fragmented code than MVC - No more hunting several folders over for a matching view to a controller method.

BTW, MVC is not a standard.

@rseyf

This comment has been minimized.

rseyf commented May 16, 2018

@JAugustoGuimaraes Please don't spam in this github issue. As you know, one of the .NET framework cross platform architects is Miguel de Icaza, one of the most notable developers of linux kernel/Gnome/Mono/Wine and other OSSs so if you don't like the Microsoft , please express your emotions outside of this issue page.

If you want to start a discussion with me about this or spam , my email address is rseyf2017@gmail.com .

So please just submit technical issues about documentation here.

Thanks.

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented May 16, 2018

I have a lot of projects on VS2013 and the tecnical issue is the need to remake all applications because the standard MVC has no future any more and the reason to change is not acceptable. I was expectating and believing a lot in Asp.Net Core. I don't like this kind of Microsoft bahavior.
I will not spam this issue anymore and I will not wait for any thing bether from Microsoft.
I lost my time waiting for ASP.Net Core to update the all applications and I will move all applications to PWA (React, Vue, Angular, etc). Thank you all to make clear the direction to follow.

@davidfowl

This comment has been minimized.

Member

davidfowl commented May 16, 2018

@JAugustoGuimaraes you'll be happy to know that Razor pages is part of MVC. They are built from the same core and share 80% of the features. If you prefer to use the MVC pattern with views feel free to continue doing so, it's not going anywhere.

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented May 16, 2018

@davidfowl, Thank you. Yes, a litle bit more of life. As you know, the first ASP still working today, but without any new feature or tools. With focus only on RazorPages (like many examples in Asp.Net Core Docs) MVC will be like ASP soon. Have you tryied to migrate a usefull real MVC application that uses OAuth2 from Asp.Net core 1.1 to 2.1 without tools? ...and about migrate from Asp.Net 4.6/7? My read from Microsoft is forget the path to grow of current things and bring back the old ones ( ..like Web Matriz/.aspx pages). Lets wait for Asp.Net Core 3 to see whats is the way!!

@Erwandebenaze

This comment has been minimized.

Erwandebenaze commented Oct 30, 2018

Hi !
I'm using MVC because my manager told me that we need different views for one action from Controller. And with Razor, it's one view for one action. So if we use Razor it will multiplicate the code !

@Ponant

This comment has been minimized.

Ponant commented Oct 30, 2018

It seems that some past parts of the discussion are missing in this post. For instance, I remember @scottsauber giving an explanation on why he prefers RP for server-side html scenario, but I can't find it. It has been referenced here, too https://stackoverflow.com/questions/46777404/why-is-razor-pages-the-recommended-approach-to-create-a-web-ui-in-asp-net-core-2
Is anyone encountering the same issue?

@scottsauber

This comment has been minimized.

Contributor

scottsauber commented Oct 30, 2018

@Ponant - It's buried in the "hidden items" now that this thread is so long. You can read that noob's comment here: #6146 (comment) 😄

For the record - up to well over 100 pages now on that app and my opinion on Razor Pages is still the same.

I was making some updates to a MVC5 app, and it struck me how much more boilerplate there is to MVC. [HttpGet], [HttpPost], [ValidateAntiForgeryToken], passing the ViewModel param in the method of the Post, Attribute Routes, new'ing up a ViewModel and passing it into like View(/* model goes here */), etc. Just stuff I never have to worry about with Razor Pages.

I'll probably write up a blog post on a comparison when I get some time.

@Erwandebenaze - You can still share views in Razor Pages with a Partial view.

@Ponant

This comment has been minimized.

Ponant commented Oct 30, 2018

@scottsauber , ok! Unfortunately I wanted to have a look at how you managed with view models how you do binding as there seems to be different ways to do that in RP and my head is banging. I remember you showed up some links on how you setup view models and so on and I said to myself I will get back to that.

@Ponant

This comment has been minimized.

Ponant commented Oct 30, 2018

@scottsauber , I remember that you where a fan of features folder, and I use it extensively too. Do you mind saying what you gain more from RP over Features folders? It seems that it relates to the antiforgery token and perhaps that it collapses the files, but other than that I have all files in the same folder(s). But there are other things which I am missing, what's your take on the difference?

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Oct 30, 2018

Do you mind saying what you gain more from RP over Features folders?

There are several listed in #7801

@Ponant

This comment has been minimized.

Ponant commented Oct 31, 2018

@Rick-Anderson , sorry I did not see a mention on RP vs Feature Folders in your link. My understanding is that you have one razor page for one action, because the page directive turns it into one and only one action. If that is correct, then the number of files will double with the number of actions. With a feature folder structure the number of files will be lesser or equal. Now you can say that the difference will lie in the View Model, but there have been several comments saying that you need to create View Models anyway with RP. This is why I ask the question to someone who is using it with 100+ pages.

@Ponant

This comment has been minimized.

Ponant commented Oct 31, 2018

I just looked up @ardalis paper https://msdn.microsoft.com/en-us/magazine/mt842512.aspx and checked up his repo https://github.com/ardalis/OrganizingAspNetCore where you have traditional MVC, Feature folder and RP side by side. I don't see an advantage of using RP over feature folders when it comes to the number of files. Furthermore, I learned that the BindProperty attribute also works on controllers, so this reduces the differences to RP significantly in my eyes.
Unless someone argues differently, I find the inclusion of RP and traditional MVC in the docs rather confusing.

  1. Identity is now entirely RP in the templates, which makes it a problem to work with identity server
    IdentityServer/IdentityServer4#2664
  2. The docs have no clear distinction between the two approaches, starting with the security/identity part
  3. I was interested in RP because people say it is more like MVVM and I had experience in uwp, but that argument seems weak, too.

Honestly it is confusing and the docs are a bit offset in terms of updates to the latest sdk.

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Oct 31, 2018

@Ponant - @scottsauber contributed to that PR and lists several advantages.

Did you read what @scottsauber wrote?

@Ponant - It's buried in the "hidden items" now that this thread is so long. You can read that noob's comment here: #6146 (comment) 😄

@Ponant

This comment has been minimized.

Ponant commented Oct 31, 2018

@Rick-Anderson , yes I read the changes he submitted and also read the comments by others and I did not see a comparison to feature folders. I may be wrong but it seems that if you remove the "easier structure" argument, then I do not see an advantage of RP because feature folders offer this and there is a nice api by @OdeToCode that allows you to have a Pages folder with a controller and view all in one and you can subfolders and areas. Regarding routing, I just don't see the advantage neither, attribute routing is very nice in MVC and practical, you can make it strongly typed by setting up a static file in a way similar to a sitemap. My argument 1 above remains a substantial one and I do not see it going away anytime soon because I just can't imagine how third parties will now switch to RP and Identity Server is a great example widely used. Recently, @blowdart mentioned in NDC that the team is working on having IS4 integrated in the template. While I think this is great, I am not sure if he is not struggling with the choice RP vs traditional MVC for that template to come. This is similar to what I am experiencing and to what others have said. In my previous projects I took the asp.net identity template and worked it out to fit my needs. As .Net Core experienced significant changes since 1.0 with the security API, I often had to take a look at the new templates to see how changes occurred (security is important!). My first question with RP was then: Is it really much better, much more powerful to justify a change? And it seems from this discussion that the answer is a no if you use feature folders.

@Ponant

This comment has been minimized.

Ponant commented Oct 31, 2018

@Rick-Anderson , I think that, in short, if you want a fair comparison, then compare with feature folders and make feature folders as the default MVC template.

@rjean99

This comment has been minimized.

rjean99 commented Oct 31, 2018

I'm currently going through both tutorials so I can compare the results. My main concern is which approach will provide the most flexibility for customization and simple integration of 3rd party controls (ie. DevExpress, Bootstrap, etc.) not so much pure speed/ease of coding

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Oct 31, 2018

@Ponant

I don't see an advantage of using RP over feature folders when it comes to the number of files.

I've debated that with @ardalis in the past. RP can have more files, but that's OK. We're not saying RP has less files and that makes it better.

I am not sure if he is not struggling with the choice RP vs traditional MVC for that template to come.

I can assure you he's not.

I think you have two misconceptions:

  • Files/Folder is the major advantage.
  • RP is much different from MVC

Is it really much better, much more powerful to justify a change

It's trivial to go from one to the other. Almost all the APIs you use are identical. I think a much better question "Are the small differences between RP and MVC with controllers/views worth going to RP?".

To me the biggest advantages of RP over MVC with controllers and views:

  • No bloated controllers. More focused/natural pages with RP. Makes it easier to update/maintain.
  • Easier to go from RP Model to Razor file.
  • No need to mock controller features you're not using.

When I ported Get started with ASP.NET Core MVC to RP I saw a minimal advantage. When I ported ASP.NET Core MVC with Entity Framework Core - Tutorial 1 of 10 to RP I realized a nice productivity boost. The EF/RP app is trivial compared to a real production app, but it's complicated enough to show the advantages.

Most of the dev's I've talked to who prefer RP to MVC with controlers/views had similar experiences. They were only convinced after developing with RPs.

@Ponant

This comment has been minimized.

Ponant commented Nov 1, 2018

@Rick-Anderson , thanks for taking the time to answer.

  1. What about the other points raised? They are to me the most important ones to my eyes to encourage people to use it, because everyone is interested in productivity boost and third party integrations. I understand that you can use RP and traditional MVC in the same project to support third parties but it makes you switch between concepts, taghelpers (asp-page vs asp-controller for instance, ignore the antiforgerytoken attribute in RP, etc), and that is a bit so so, especially if you go through the docs. For instance, the Security part with claims, policies etc uses traditionally controllers as of today
    https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-2.1

  2. I knew that RP is based on MVC so I did not expect it to be much "different". I followed up the RP from the early on live.aspnet and supported the idea because of the "code behind" structure. I may have had one misconception over the two you mention, namely that the folder/fils structure is the biggest advantage, but quite sincerely this argument popped up throughout the standups and is there in the docs, at least implicitly. Perhaps the difference lies in English wording.

  3. I was wondering a poll will not help you out to see real stats. A one-question poll that will ask the question:
    -Do you prefer traditional MVC over RP and a checkbox "I already tried RP". That can be set up easily with Forms, I can do it if it helps.

@ProfBird

This comment has been minimized.

ProfBird commented Nov 3, 2018

I teach web development at a community college. My goal is to teach students concepts that are generally applicable regardless of what programming language or framework they end up using once they get a job. If I were to teach RP, then they would be learning an esoteric framework that shares little with other mainstream frameworks. By teaching ASP.NET Core MVC, they are learning concepts that will transfer to other MVC frameworks.

It is true that MVC is not a "standard" in the formal sense of the word, but most mainstream MVC frameworks have more similarities than differences and once you've learned one it's easy to learn another. In that sense MVC is a standard design pattern.

My time is valuable, I don't want to spend it learning a set of concepts and design patterns that only work with one framework. This year I'm using C# and ASP.NET Core MVC, next year I might need to be using Python and Django, or Ruby on Rails, or who knows, but at least I'll already have a good foundational set of concepts that I can transfer.

@OdeToCode

This comment has been minimized.

OdeToCode commented Nov 5, 2018

You'll find the same concepts in RP that you find with ASP.NET MVC and other frameworks both server-side and client-side.

  1. A separation of concerns - a page method builds a model to give to a view. The model knows nothing about the view. The view will focus only on presentation. This is the same separation of concerns the MVC side of the framework uses, but without the artificial separation of spreading all the files I need to work on a single logical page across three physical directories. I'm certain that the people in this thread who say RP doesn't maintain the same SoC as MVC haven't tried to develop with RP.

  2. Separate deciding from doing - the page method doesn't write into the response stream, instead the page method returns a data structure that tells the framework what to do next. This practice makes unit testing easier, and also grants additional flexibility with action filters and page filters that can set up a pipeline design and take care of cross cutting concerns. The base abstraction for resulting is the same as the MVC side of the framework - IActionResult.

  3. Dependency inversion principle - a page method should be programming to abstractions and not concrete details. The page constructor can advertise what dependencies are needed so the framework can inject the dependencies. This feature works the same as the MVC side of the framework.

Each of these three points includes the phrase "the same as the MVC side of the framework", and if I had the time, I could list many more example of where RP and MVC share the same patterns, and even the same abstractions. I'm also sure I could list 100s of fundamental webdev concepts you can teach with Razor pages that are more important than any framework - the POST-Redirect-GET pattern, preventing XSS, how cookies work, etc.

@ProfBird

This comment has been minimized.

ProfBird commented Nov 5, 2018

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Nov 6, 2018

@ProfBird

ASP.NET Core MVC, they are learning concepts that will transfer to other MVC frameworks.

ASP.NET Core MVC and RP share show much in common it's easy to learn and use them both in parallel. It's trivial to go from MVC to RP and vice-versa. It's much more difficult to go from ASP.NET Core MVC to Spring MVC.

It is true that MVC is not a "standard" in the formal sense of the word, but most mainstream MVC frameworks have more similarities than differences and once you've learned one it's easy to learn another.

Try the EF/MVC tutorial and the EF/RP tutorial, it's really trivial going from one to the other. Try going from ASP.NET Core MVC to Spring MVC, that's not so easy.

Many potential employers won't recognize RP while they will recognize MVC,

Learn them both - no employer will complain about that.

@tstivers1990

This comment has been minimized.

tstivers1990 commented Nov 6, 2018

Many potential employers won't recognize RP while they will recognize MVC,

Learn them both - no employer will complain about that.

Honestly, this. It took me very little time to become proficient with RP coming from ASP.NET Core MVC. I don't understand why the resistance to it seems so strong.

@sparkeh9

This comment has been minimized.

sparkeh9 commented Nov 7, 2018

I am using both RP and MVC. I don't see RP as a replacement for MVC, instead it is a supplement.
I wouldn't use RP for anything more complex than a contact form or something

@plamenyovchev

This comment has been minimized.

plamenyovchev commented Nov 8, 2018

Because I do not like Razor Pages.

@Miggleness

This comment has been minimized.

Miggleness commented Nov 9, 2018

I was looking for open source Razor tooling and fell into this hole. Just... wow.

@rexbroo

This comment has been minimized.

rexbroo commented Nov 9, 2018

@datvm

This comment has been minimized.

datvm commented Nov 10, 2018

From someone who hated Razor Page when reading the tutorial/overall architecture because it reminded me of the old Web Form time: Just try it on some projects, you will love it. Even if you don't like it, no matter, the same project can still be developed with your good-ol MVC. I even have a project that mixes both (MVC for API, Razor for UI), and I have to say Razor Page is so much better than MVC for UI only pages.

And as others have said, learning both is actually the wisest, and it does not take much time of you anyway.

@JAugustoGuimaraes

This comment has been minimized.

JAugustoGuimaraes commented Nov 11, 2018

Why push RazorPage over MVC instead add RazorPage as new Feature? What is wrong with MVC??

@ccit-spence

This comment has been minimized.

ccit-spence commented Nov 12, 2018

In the 2.0 docs a long tutorial is listed for MVC. Razor Pages docs do not list an equivalent of that documentation. Documentation, Blogs, Tooling, Examples in the wild for MVC far exceed what exist for Razor Pages.

Soon the 2.2 documentation will become GA. Are we then still forced to go back to an MVC long tutorial in 2.0?

Razor Pages look promising, just not as mature of an ecosystem.

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Nov 12, 2018

@ccit-spence

In the 2.0 docs a long tutorial is listed for MVC. Razor Pages docs do not list an equivalent of that documentation.

What tutorial is that?

Documentation, Blogs, Tooling, Examples in the wild for MVC far exceed what exist for Razor Pages.

It's usually trivial to go from MVC tutorials to a RP version.

@ccit-spence

This comment has been minimized.

ccit-spence commented Nov 12, 2018

This is the tutorial.
https://docs.microsoft.com/en-us/aspnet/core/data/ef-mvc/?view=aspnetcore-2.0

RP does not translate 100% to MVC. I understand why. It does present a better workflow. The issues come in the subtle differences.

@Rick-Anderson

This comment has been minimized.

Contributor

Rick-Anderson commented Nov 12, 2018

There is a RP version of that tutorial, sans the last two stages. Having converted the MVC version to RP, I saw the advantages of RP. The conversion from MVC to RP was trivial.

@Ponant

This comment has been minimized.

Ponant commented Nov 13, 2018

It is important to talk about the differences between MVC and RP, not the similarities!
And I am sorry to say that saying that learning both is the wisest is correct only under certain circumstances in your work or life, but it is certainly not something you should recommend to everyone.

There is one fundamental aspect that keeps being left unanswered on this thread and others and this is Authorization, Claims, Policies. At one time there was a workshop which allowed me to go through the fundamental understanding of Authorization in .Net Core and it was just perfect for a beginner in the field to greatly understand how to secure with a big S the http request flow. This workshop was by @blowdart , and I just realize now that it has been updated to .Net Core 2.1, great but you know what ?: It is the traditional MVC https://github.com/blowdart/AspNetAuthorizationWorkshop , also see dicussion going back to May 2018 #6301.

So now you have the following confusion and please stop saying that the shift is trivial because this is inappropriate if you want to teach or diffuse knowledge and further more I disagree that this is as trivial when considering authorization because the security tests one must do need to be double checked:

  1. You want to check out how Auth works in .Net Core, you head to perhaps the most important feature, Policies, https://docs.microsoft.com/en-us/aspnet/core/security/authorization/policies?view=aspnetcore-2.1 , with guidlines using MVC

  2. You popup ASP.NET Identity from a template .Net Core 2.1 since there has been some major changes since 1.0, and you get a template with no access to the Identity code !

  3. To access this code you start scaffolding, painfully and with still unresolved issues aspnet/Scaffolding#839 , which means you need to go through the code and correct the scaffolding, such as substituting IdentityUser for ApplicationUser . Notice that you will most likely need to scaffold identity in 80%-90% of your projects, so this is extra work the dev needs to do while trying to keep focus. Once you scaffold you get RP based Identity.

  4. Now you have the Authorization workshop with controllers and a scaffold identity with RP. OK, now you have to go through linking the two.

  5. If you look for setting up an Auth flow with admin, restricted privileges, and read only users, for instance, you can head to here https://docs.microsoft.com/en-us/aspnet/core/security/authorization/secure-data?view=aspnetcore-2.1 . This step-through uses RP.
    If you compare this with @blowdart 's Workshop with the tuto then you start seeing a difference because the former uses extensively code based policies because you need to go beyond the authorize attribute by requiring you to check explicitly for auth, such as
    var isAuthorized = await AuthorizationService.AuthorizeAsync( User, Contact, ContactOperations.Create); if (!isAuthorized.Succeeded) { return new ChallengeResult(); }
    whereas the latter is more elegant and above all more secure as less error prone as large parts use the [Authorize(Policy="blabla")] (you get rejected before entering the action) and then follow up with a scenario similar to above. It is not clear if you can continue to use the authorize attribute in this scenario for RP otherwise it would have been used in the tuto above or another.

  6. Now you want to plugin IdentiyServer which has a template based on .Net Core 2.0, with controllers. OK so you need to port to RP, right? I am not sure they will.

To me the bottom line is that RP has been promoted too early, is imposed inappropriately with Identity (which furthermore is in a library), the docs are not ready, they mix both with links amazingly empty and I hope you will accept or at least understand that this is not "easy" or "trivial" to switch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment