簡體   English   中英

ASP.NET MVC FileNotFoundException錯誤

[英]ASP.NET MVC FileNotFoundException error

我有一個與之前的帖子有關的奇怪錯誤。 下載前我正在檢查文件是否存在。 這適用於PDF,但不適用於任何其他類型的文檔。

這是我的控制器操作,以及PDF和PowerPoint文件的典型路徑,PowerPoint不起作用, File.Exists始終返回false 這兩個文件實際上都存在。 這非常令人困惑,因為它會導致非PDF的FileNotFoundException

/Documents//FID//TestDoc//27a835a5-bf70-4599-8606-6af64b33945d/FIDClasses.pdf

〜/ Documents // FID // pptest // ce36e7a0-14de-41f3-8eb7-0d543c7146fe / PPttest.ppt

開玩笑的是,將文件路徑復制並粘貼到資源管理器中會導致文件,那么可能是什么問題呢?

[UnitOfWork]
public ActionResult Download(int id)
{
    Document doc = _documentRepository.GetById(id);

    if (doc != null)
    {
        if (System.IO.File.Exists(Server.MapPath(doc.filepath)))
        {
            _downloadService.AddDownloadsForDocument(doc.document_id, _UserService.CurrentUser().user_id);
            return File(doc.filepath, doc.mimetype, doc.title);
        }
    }
    return RedirectToAction("Index");
}

檢查PPT文件和目錄的權限,檢查文件沒有附加“區域”信息,因為您是從其他地方下載的。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM