所以我决定试试 Visual Studio 2012 专业版。安装它并打开我的 MVC3 解决方案后,我在 ((WebViewPage)WebPageContext.Current.Page).Html; 其中 WebPageContext.Current 为空。不好的想法是:即使在检查了“干净”解决方案并使用 Visual Studio 2010 打开它之后,我仍然会遇到同样的异常,而其他项目成员却没有。发生异常的地方在这篇文章中有特色。代码:
// Workaround - exposes the MVC HtmlHelper instead of the normal helper
public static new HtmlHelper<object> Html
{
get { return ((WebViewPage)WebPageContext.Current.Page).Html; }
}