我有一个异常抛出这一行,不能弄清楚为什么…也许有人可以发现它
<img src="@{Model.Image != null ? Model.Image.FileName : "";}" width="200px" id="ImagePreview"/>
我得到的例外是:
error CS0201: Only assignment,call,increment,decrement,and new object expressions can be used as a statement
解决方法
@H_502_11@ 您需要为该表达式使用表达式(显式)代码块样式:<img src="@(Model.Image != null ? Model.Image.FileName : "")" width="200px" id="ImagePreview"/>