【发布时间】:2018-03-20 15:48:46
【问题描述】:
我有一个简单的控制器,它创建一个模型,其中包含一个表示 log4net 日志文件的自定义对象列表。
日志文件夹的路径是/Logs/。在视图中,我得到了完整的文件名。我需要建立一个正确的文件下载链接:
我尝试过<td><a href="@("/Logs/" + file.FileName)" title="@file.FileName" target="_blank">@file.FileName</a></td> 和产品http://localhost/Logs/Finance-Web-2018-03-20.log
我尝试了<td><a href="@("~/Logs/" + file.FileName)" title="@file.FileName" target="_blank">@file.FileName</a></td>,得到了http://localhost/finance-web/Administration/~/Logs/Finance-Web-2018-03-20.log
两者都是错误的。在我的情况下,链接应该是http://localhost/finance-web/Logs/Finance-Web-2018-03-20.log
finance-web 是 IIS 虚拟文件夹
如何获得正确的地址?
【问题讨论】:
标签: c# asp.net-mvc