Will this introduce two problems? The first is that the view is now a bit coupled to the controller because it has to know the name of the string that the controller sets in ViewData/TempData. The second is that these are loosely typed, which means there is no Intellisense. If I am developing Controller, I can’t tell another developer working on the view to only use Intellisense as the model, I have to give him the name of the string, if I change the string name, I also have to change it in the view.
I think the final question I have to ask is, is this correct? Or what am I not understanding?
I hope it will help.
I have a question about keeping the controller and the view separate. In my opinion, the controller should only be the model Passed to the view, the view decides how to display the model. In this way, the controller and the model remain independent and can be developed independently. However, I have seen many tutorials on the Internet, and even in the book Pro ASP.NET MVC Framework, I have seen many uses Examples of ViewData [“string”] or TempData [“string”].
Will this introduce two problems? The first is that the view is now a bit coupled to the controller because it has to know the name of the string that the controller sets in ViewData/TempData. The second is that these are loosely typed, which means there is no Intellisense. If I am developing Controller, I can’t tell another developer working on the view to only use Intellisense as the model, I have to give him the name of the string, if I change the string name, I also have to change it in the view.
I think the final question I have to ask is, is this correct? Or what am I not understanding?
Viewing data is a way to pass information between the view and the controller, but as you said, without wisdom, it increases coupling. On the contrary. , You should consider using ViewModel. For the way to use ViewModel and the advantages and disadvantages of ViewDate and ViewModel, please refer to Scott Gu NerdDinner example (available for free).
I hope it will help.< /p>