Have a question about the design/usage of asp.net mvc here.
In the html helper class, you can get to the current controller by Html.ViewContext.Controller. Moreover, you can get to the request, route collection and much more from the html helper class.
Doesn't this go against the rule of MVC? Doesn't this opens up a ways for developer to do heavy controller dependent code in views?
If not, what's the best practice use case for current viewcontext and controller from the html helper class?
Thanks in advance.
Use a strong typed ViewModel, so your view is only dependant of it and not of the controller who generates it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With