iframe中的Razor和奇怪的Html.Raw编码

时间:2018-12-13 17:30:30

标签: c# asp.net razor

我使用ASP.NET Framework(v4.5.1)。

剃刀视图中的以下行

<iframe 
data-mytest="@Html.Raw(greetingLink)" 
        src="@Html.Raw(greetingLink)" width="430" height="300" frameborder="0" allow="autoplay" title="video youtube"></iframe>

在生成的页面的代码源中给出以下结果:

<iframe  
data-mytest="https://www.youtube.com/embed/gVIFEVLzP4o?autoplay=1&showinfo=0&controls=0&rel=0" 
        src="https://www.youtube.com/embed/gVIFEVLzP4o?autoplay=1&amp;showinfo=0&amp;controls=0&amp;rel=0" width="430" height="300" frameborder="0" allow="autoplay" title="video youtube"></iframe>

如果您观察到,则第二个URL是URL编码的(& => &amp;)。什么会产生这样的行为,即同一@Html.Raw(greetingLink)代码产生一次未编码,而第二次产生编码后的字符串?

0 个答案:

没有答案