将 Rich Cards 数据添加到我的 dotnet 应用程序导致它崩溃

Adding Rich Cards data to my dotnet application cause it to crash

我正在尝试将 Rich Cards 添加到我的 dotnet 应用程序中。

所以,如果我尝试添加这个:

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Organization",
  "url": "http://www.t-mobile.com",
  "contactPoint": [{
    "@type": "ContactPoint",
    "telephone": "+1-877-746-0909",
    "contactType": "customer service",
    "contactOption": "TollFree",
    "areaServed": "US"
  }]
}
</script>

然后我收到这条很长的错误消息:

Microsoft.AspNetCore.Server.Kestrel[13] Connection id "0HL8COF5253MA": An unhandled exception was thrown by the application. Microsoft.AspNetCore.Mvc.Razor.Compilation.CompilationFailedException: One or more compilation failures occurred: /Views/Shared/_Layout.cshtml(70,7): error CS0103: The name 'context' does not exist in the current context /Views/Shared/_Layout.cshtml(71,7): error CS0103: The name 'type' does not exist in the current context /Views/Shared/_Layout.cshtml(74,7): error CS0103: The name 'type' does not exist in the current context

似乎它试图解析@type 和@context 但无法识别它所以它崩溃了。我可以如何防止这种情况?

您需要避免出现 @ 的情况,剃须刀将使用 @@ 处理它不会处理的