c# - Check if (partial) view exists from HtmlHelperMethod -
does know if it's possible check if partial view exists within htmlhelperextension?
i know it's possible controller using following:
private bool viewexists(string name) { viewengineresult result = viewengines.engines.findview(controllercontext, name, null); return (result.view != null); }
source: does view exist in asp.net mvc?
but can't above in helper, don't have access controller context. thoughts on how this?
but can't above in helper, don't have access controller context.
oh yes, have access:
public static htmlstring myhelper(this htmlhelper html) { var controllercontext = html.viewcontext.controller.controllercontext; var result = viewengines.engines.findview(controllercontext, name, null); ... }