A simple question though. I am creating a sample AP.NET MCV 3 site using Razor as view engine. The razor syntax starts with @
character e.g. @RenderBody()
. If I write @test on my cshtml page it gives me parse error CS0103: The name 'test' does not exist in the current context
. How do i escape '@' character?
views:
98answers:
2
+1
A:
@@ is the escape character for @ in Razor views as stated above.
Razor does however try to work out when an '@' is just an '@' and where it marks C# (or VB.Net) code. One of the main uses for this is to identify email addresses within a Razor view - it should not be necessary to escape the @ character in an email address.
Alfamale
2010-09-13 13:31:21