为什么iis用asp net mvc控制器文件流返回403错误代码?

问题描述 投票:1回答:1

我有一个控制器,有两个方法

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张图片没有显示,我没有实施任何认证,所有文件都在同一台机器上。

c# asp.net asp.net-mvc iis-8.5
1个回答
0
投票

好了,这就是我的解决方案。

需要在IIS 8.5中设置下限。

https:/serverfault.coma908740。

© www.soinside.com 2019 - 2024. All rights reserved.