2

I am trying to add Rich Cards to my dotnet application.

So, if I try to add this:

<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>

Then I get this long error message:

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

Seems it tried to parse @type and @context and doesn't recognise it so it crashes. Can I prevent this some how?

ganjan
  • 7,356
  • 24
  • 82
  • 133

1 Answers1

3

You need to escape the single occurrence of @ that razor will pick up on with @@ which it'll know not to process

DiskJunky
  • 4,750
  • 3
  • 37
  • 66