Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用 mvc 4 并创建了一个自定义 HtmlHelper。
是否可以从该助手内部访问正在调用该助手的视图?我想在我的辅助方法中使用基础视图上的属性。
是的你可以 :)
public static void MyExtension(this HtmlHelper html) { var view = html.ViewDataContainer; // accessing view properties var viewModel = view.Model; var viewAjax = view.Ajax; // etc }