razor pages vs .cshtml
Team , What is the difference between razor pages and cshtml.?
razor pages looks like old asp.net web pages aspx and aspx.cs where views were tightly coupled to code behind(ASPX.CS).
there was some drawbacks like tightly coupling in asp.net web forms and then comes mvc .
what was the reason to bring razor pages and code behind again?
any architectural reason?
2 Replies
To be clear, Razor Pages still use
.cshtml
files and Razor syntax, just like MVC with views
The reason is that it's all sorted much more nicely
Instead of
you have a nice and clear
No need to jump through three (at least) different folders, you have everything in one place
The model and the controller are also one and the same, basically
Which, sure, limits what you can do somewhat (can't return different views from the same handler, for example) but makes other things much easier
Instead of passing around objects, you set and get properties
And that the model is coupled to the handlers? Does it really matter, considering models shouldn't be shared between different views?ok understood @ZZZZZZZZZZZZZZZZZZZZZZZZZ thank you for clarifying