English 中文(简体)
利用“手法”连接一个电离板页。 Tiktok URL使用“@”,但在cshtml中出现错误
原标题:Using "href" to link a tiktok page. Tiktok URL use "@", but get error in cshtml

我想用“href”将一页kt子连接起来,但我认为,由于“@”这一推土机默认它会造成错误。

我试图使用以下两种合成物,但在浏览器中,错误似乎是:“在字面上有许多特性”(图1)和“目前情况下不存在“tiktok”的名称”(图2)。

 <li>
   <a href="@( https://www.tiktok.com/@tiktok.example1?lang=en/ )">
      <img src="/assets/img/social-tiktok.svg" alt="Tiktok Icon">
   </a>
 </li>
 <li>
   <a href="https://www.tiktok.com/@tiktok.example2?lang=en/">
      <img src="/assets/img/social-tiktok.svg" alt="Tiktok Icon">
   </a>
 </li>
问题回答

该员额详细说明了为html逃避特性的途径。 如果你不需要积极这样做,你就只能用<>%40取代@。

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!

i 试图将@替换为&#64;,并为我工作。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签