Image display on MVC view

后端 未结 2 1015
清歌不尽
清歌不尽 2021-02-01 15:28

I am trying to display image on the cshtml file. The spam filter prevents me from typing the HTML for image. However the source is set to

src= \"@Html.Encode(Mod         


        
相关标签:
2条回答
  • 2021-02-01 15:55

    You have specified an absolute path which doesn't exist on the client computer. Try like this:

    <img src= "@Url.Content("~/uploads/FileUpload12011_03_02_11_49_22.jpg")" alt="IMAGES" />
    

    or if your model variable contains "~/uploads/FileUpload12011_03_02_11_49_22.jpg" you could:

    <img src= "@Url.Content(Model.PictureLocation)" alt="IMAGES" />
    
    0 讨论(0)
  • 2021-02-01 15:58

    The path in the src attribute must be relative to the website root, not the absolute path on the server. So in your case that would probably be something like "/uploads/FileUpload12011_03_02_11_49_22.jpg".

    0 讨论(0)
提交回复
热议问题