在 CloudScribe SimpleContent 中使用本地 cshtml 文件时编译错误



我正在'剥皮'Cloudscribe的博客引擎SimpleContent,并在本地复制了必要的部分视图,让我可以编辑控制html。有两个视图在运行时给我一个错误,即ArvhieListPartial.cshtml和CategoryListPartial.cshtml。

该错误在两者中是相同的,并且在任何其他与博客相关的 cshtml 页面中都不存在:

<li>
<a asp-route="@blogRoutes.BlogArchiveRouteName"
asp-route-year="@cat.Key.Substring(0,4)"
asp-route-month="@cat.Key.Substring(5,2)">@cat.Key.Replace("/", "-")(@cat.Value)</a>
</li>

@cat.Key是错误点,浏览器会报告:

非可调用成员 KeyValuePair<string,>.键不能像方法一样使用。

我注意到这两个部分视图是唯一在顶部有引用的视图,如下所示:

@model Dictionary<string, int>

我正在使用Visual Studio 2017版本15.2(26430.16(

我认为这是因为您删除了这些之间的空格

@cat.Key.Replace("/", "-")(@cat.Value)

原始视图在那里有一个空格,但通过删除它 Razor 正在解释 (就像方法签名的开头,而不是它想要的文字文本,并且由于它只是一个字符串属性,它会引发此错误,因为它解释您像方法一样使用它

最新更新