MVC - Razor Edit and View mode implementation on Model(s) and Controller(s)

I have these different Razor views on my project:
  • For editing: Image 1
  • For view only mode: Image 2
    What I want:
  • Use only one View file Edit.cshtml for displaying or editing the models.
    What I have:
  • At the moment, I have 2 separate methods and views for editing/displaying the model.
    What I could do (probably):
  • Use one view for both, and conditionally display what I want/need in edit/display mode.
  • But I've read that programmatically adding conditions of this kind on Razor, is not the best approach/practice.
So:
What can I do? How have you tackled this problem?
unknown.png
unknown.png
Was this page helpful?