You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET 6 MVC中嵌入Instagram图片遇@账户名报错的解决方法

.NET 6 MVC视图中Instagram嵌入代码@符号报错的解决办法

核心原因

在.NET Razor视图里,@是触发服务器端代码解析的特殊标记,嵌入代码里的@InstagramAccount会被Razor引擎误判为服务器端表达式,从而引发报错。

修改方案

直接对@符号进行转义——在Razor语法中,用两个连续的@@来表示一个普通的@符号,这样就能让页面正常渲染出Instagram账户名格式。

修改后的代码示例

<p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;"><a href="https://www.instagram.com/p/CjLy3aqO-Cw/?utm_source=ig_embed&amp;utm_campaign=loading" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">A post shared by Mely&#39;s Underground-Cuisine (@@InstagramAccount)</a></p>

内容的提问来源于stack exchange,提问作者AlThePal78

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 00:35:19