我正在尝试加载上传到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");
}