如何将 @Model 字符串放入 html 字符串中

How to put a @Model string inside a html string

如何将 @Model 字符串放入 html 字符串中?

<img src="/img/users/@Model.Short.jpg.ashx?width=80&height=80" width="80" height="80" alt="" />

@Model.Short 是我需要作为 img src 一部分的字符串。我遇到的问题是它给出了一个错误,因为它认为 .jpg.ashx 是 @Model.Short 的一部分并且不知道它应该按原样打印。

我现在唯一能想到的就是在 JavaScript 中执行此操作,但将它 "hardcoded" 放在 html.

中更有意义

使用括号:

<img src="/img/users/@(Model.Short).jpg.ashx?width=80&height=80" ... />