我想创建一个应用程序,如果有 Ajax 调用它返回部分视图,如果它是页面刷新它返回布局和渲染脚本。但问题是部分视图不会呈现部分,因为我在 APP_Code 中创建了一个 MVC 助手:
@helper AddSection(Func<object, object> content)
{
if (IsAjaxRequest)
{
@content(null);
}
else
{
@section scripts {
@content(null);
}
}
}
当我在我看来调用它时,我收到以下错误:
CS0103: The name 'DefineSection' does not exist in the current context
Line 71: #line hidden
Line 72: DefineSection("scripts", () => {
Line 73:
我尝试了很多东西,但这个错误仍然存在,我也搜索了很多但找不到解决方案。