Isn't that against the MVC rule?
Yes, this is happening.
Doesn't this open up the possibility for developers to make heavy controller-dependent code in views?
Yes, he opens this door. This should be avoided.
What is the best use case for the current viewcontext and controller from the html helper class?
Best practice is that the HTML helpers are not aware of controllers and contexts. They should do their work only on the basis of what data is provided by the caller.
However, there are rare cases where you can stretch out of the box. For example, I wrote one helper that will display HTML elements and add automatically increasing identifiers to them. In this case, the assistant must store information about the previously used identifier value. Here you might want to store this value in a ViewContext, for example.
However, you should only do such things when you clearly understand what and why you are doing it.
user151323
source share