我得到变量作为@ViewBag.confile
从控制器到视图,它的工作,但我把它放入链接,但我不显示,但我链接外它显示正确。我想将这个@ViewBag.confile
变量添加到href tag
中,这是我代码中的错误。我该如何实现呢?这是我的代码
我正在使用asp.net MVC 4
<a href="http://localhost:64049/Content/" @ViewBag.confile >Download Converted File @ViewBag.confile</a>
@ViewBag。配置文件变量在视图中正确显示,但问题是当我点击链接时,我做HTTP Error 403.14 - Forbidden error
web浏览器地址栏只显示http://localhost:64049/Content/
@ViewBag.confile
变量缺失
可以:
<a href="http://localhost:64049/Content/@(ViewBag.confile)">Download Converted File @(ViewBag.confile)</a>
您应该真正使用tilda语法来允许MVC解析引用:
<a href="~/Content/@( ViewBag.confile )">Download Converted File @ViewBag.confile</a>