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?

4
  • 1
    Escape the @ with @@ to prevent razor from picking it up Commented Oct 6, 2017 at 14:54
  • 1
    trying to set your answer as the solution, but that option doesn't show up after editing the question... Commented Oct 6, 2017 at 15:56
  • Added comment as answer, you'll be able to mark it as the solution Commented Oct 6, 2017 at 15:58
  • Do not add answers in the question Commented Oct 7, 2017 at 8:09

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.