I have a partial idea that I want to be general. According to this question , partial representations cannot be shared. So instead, I made the HtmlHelper extension, which processes the parts for which I want a security type, and then defers the rest to a real partial view.
Usually my helper is called when a page loads, which works fine, but sometimes I want to add a line or something through AJAX. When this happens, the controller cannot use my "partial view", since it does not have access to the HtmlHelper.
Besides a partial view with a model like object , is there anything I can do?
I use Razor if this is important.
A simplified version of what I'm doing:
public static MvcHtmlString DoStuff<T>(this HtmlHelper html, IEnumerable<T> data, Func<T, ViewModelType> StronglyTypedFn, string PartialName) {
I understand that in this example I have so few lines of code outside the partial view that it seems pointless to have a helper, but in my real example it is more complicated.
Now, in ajax call, I want to return Html.DoStuff() . But I can not, because this requires access to the HtmlHelper, and the helper is not available inside the controller.