Aritra B
Aritra B

Reputation: 1746

MVC 4 Error in Layout / HTML

I have got a HTML template which I have added with a .cshtml extension in the application and have made some changes in the file. I have got a large part of the html commmented out and whenever I call this layout on a view. It comes up with an error which is as follows :

"<" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

Here is the Code:

<li><strong>@<a href="#">name</a></strong> <span class="tweet_text">RT <span class="at">@</span><a href="#">name</a> 

It shows that the error has occurred in line 240 and line 240 is something like this: Can anyone help me out with this with? Why is the error showing? Any help will be much appreciated! Thanks in advance!

Upvotes: 1

Views: 226

Answers (2)

Tieson T.
Tieson T.

Reputation: 21246

You can also simply use another @ to escape it: @@ will render as @ in the generated markup.

Upvotes: 1

Joe Marie
Joe Marie

Reputation: 346

that is because @ is like a reserve word in cshtml, it is likely followed by { and enclosed in }, example:@{var message = "Hello World!";}, I think if you want to use that character you must enclose it in <pre>@</pre> tag.`

Upvotes: 0

Related Questions