I just came across this as I was having a similar issue.
the only problem is that I have to call this in a view with @model in order for it to work, otherwise attributes will always be empty
The simple answer is that you can't because without the @model
directive defining the type, the view assumes that the model is dynamic
and so the HtmlHelper
parameter of the extension method will actually be IHtmlHelper<dynamic>
. That is my understanding.
If you have since found an way round this, please let me know.