我使用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&showinfo=0&controls=0&rel=0" width="430" height="300" frameborder="0" allow="autoplay" title="video youtube"></iframe>
如果您观察到,则第二个URL是URL编码的(&
=> &
)。什么会产生这样的行为,即同一@Html.Raw(greetingLink)
代码产生一次未编码,而第二次产生编码后的字符串?