Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MVC3 Model Data Separation

I've noticed in that a lot of the fields I'm putting into my views are control logic:

@if (Model.IsAdmin) {
  <p>You're an admin</p>
}

My understanding of how MVC should be working is that what goes into the model should act much more like a data, it's returned if it's a form, it's for the user to see/change, etc.

Is putting control logic in a view bad practice? What is the convention for passing control logic to a view in MVC?

like image 986
Tin Can Avatar asked Feb 25 '26 11:02

Tin Can


1 Answers

Is putting control logic in a view bad practice?

No, you could perfectly fine have view logic inside your views to conditionally show or hide some sections. Your particular example is perfectly fine in a view.

like image 159
Darin Dimitrov Avatar answered Feb 27 '26 01:02

Darin Dimitrov