Alright, with that first error, Too many characters in the character literal
, that is because when you stated @()
you started writing in CS code. That s alright, but then that means that the way that
and "
work changes. As you may know, in CS, single quotes (
) mark a type char
, so char exampleOne = a
works, because a char
can only be a single character, but char exampleTwo = ab
doesn t because a char may only be a single character length. So, @( https://www.tiktok.com/@tiktok.example1?lang=en/ )
should be @("https://www.tiktok.com/@tiktok.example1?lang=en/")
, and that would work, see the following full example.
<li>
<a href="@("https://www.tiktok.com/@tiktok.example1?lang=en/")">
<img src="/assets/img/social-tiktok.svg" alt="Tiktok Icon">
</a>
</li>
Then, the next error, The name "tiktok" does not exist in the current context
, is because, like it says, there is no variable or method or anything that is called tiktok
. This is because when you use @
in a cshtml or razor file, it assumes you re going to use a CS keyword or variable, or something related. To escape this, you have a couple options. For ease of use, stating a double @ (@@
) escapes the @
use in cshtml/razor, and turns it into a single @
char. However, if this is difficult for readability, you can use html escape character patterns, like %40
as suggested by pierrefondss
previously (here is a link to that).
Hope this helps!