Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Razor a Step Backwards? [closed]

I need some convincing on the Razor View Engine.

From what I can tell, Microsoft have simply re-introduced inline code back into markup; weren't code-behind pages originally introduced to eradicate this?

I assume (and hope) that I am missing something :)

like image 297
Lawrence Wagerfield Avatar asked Dec 01 '22 01:12

Lawrence Wagerfield


2 Answers

Razor is not for writing your business logic in your view. Razor is for iterating over model and converting it to html. Your business logic is in controller besides even in WebForms view engine you did the same looping only with a more verbose syntax. Razor has cleaner syntax. It doesn't bring anything else with it.

like image 110
Muhammad Hasan Khan Avatar answered Dec 04 '22 09:12

Muhammad Hasan Khan


razor is best used with MVC. Yes it does reintroduce inline code. but it is about separation of code.

Your razor code should not have any logic in it. It really should be used to simply get your data onto a page (small amounts of logic e.g If Data= True THen Should this section, are ok tho)

but all business logic is still in your controller/codebehind

like image 44
Steve Avatar answered Dec 04 '22 11:12

Steve