我有一个控制器,有两个方法
public ActionResult Index1(string c, string d)
{
string path = "some path";
if (System.IO.File.Exists(path))
{
var bytes = System.IO.File.ReadAllBytes(path);
return base.File(bytes, MimeMapping.GetMimeMapping(path));
}
path = "/assets/images/no.jpg";
return File(path, "application/jpeg", "no.jpg");
}
public ActionResult Index2(string c, string d)
{
string path = "some path";
string _nomefile = "some name";
string _mime = "";
if (System.IO.File.Exists(path))
{
return new FileStreamResult(new FileStream(path, FileMode.Open), _mime) { FileDownloadName = _nomefile};
}
path = "/assets/images/no.jpg";
return File(path, "application/jpeg", "no.jpg");
}
这个都是用这样的观点
@foreach (var item in Model.OrderBy(x => x.Titolo))
{
<div class="col-md-3 col-sm-12 immagini margin-bottom-20">
<a class="image-hover" href="/[email protected]&d=N" data-toggle="tooltip" title="@item.Titolo - @item.Descrizione">
<img src="/[email protected]&d=M" alt="@item.Titolo"><br />
<span>@item.Descrizione</span>
</a>
</div>
}
问题是,IIS返回一个间歇性的403 forbidden两种方法,这是完全随机的。在一个有30张图片的列表中,有3或4张图片没有显示,我没有实施任何认证,所有文件都在同一台机器上。