即使文件路径正确,图片也不会显示

时间:2019-05-15 07:56:17

标签: c# html asp.net-core

我正在尝试加载上传到wwwroot路径的图片。然后,我将文件路径保存到数据库中并进行检索以在我的视图中显示它。

保存的文件: https://pasteboard.co/IeMBH07.png

ViewBag.Photo中的文件路径:"C:\\Users\\Me\\source\\repos\\Trinity SOLID\\Trinity\\wwwroot\\Billie.jpg"

视图Img src中的文件路径:C:\ Users \ Me \ source \ repos \ Trinity SOLID \ Trinity \ wwwroot \ Billie.jpg

查看

<h1>match</h1>

<img src="@ViewBag.Photo" alt="Profile" />
<br />

控制器

public ActionResult LoadPotentialMatch()
        {
            string stringID = Request.Cookies["UserID"];
            int ID = Convert.ToInt32(stringID);
            logicmatch.TrulyPotentialMatchesList(ID);

            string value = Convert.ToString(logicmatch.pmatchID);
            SetCookie("pmatchID", value, 10);

            ViewBag.FirstName = logicmatch.FirstName;
            ViewBag.Age = logicmatch.Age;
            ViewBag.Bio = logicmatch.Bio;
            ViewBag.Sex = logicmatch.Sex;
            ViewBag.Photo = logicmatch.Photo;
            return View("match", "Matching");
        }

0 个答案:

没有答案