0

DosyaYolu.cshtml

@{
  Layout = null; 
  string dosyaYolu = Server.MapPath("~/Views/Home/Adsiz.jpg");
 }

<img src="@dosyaYolu" /> 

I could not display image from dosyaYolu path.What will I need to do?

1 Answer 1

1

Please just the pass the URL as itself. Because Server.MapPath will change the URL which can understandable by machine not by the browser.

It will be useful when the image file is inside of the your application.

Just pass the URL as

 @{
    Layout = null; 
    var dosyaYolu = @Url.Content("~/Views/Home/Adsiz.jpg");
  }

<img src="@dosyaYolu" />

Sign up to request clarification or add additional context in comments.

2 Comments

Did you check path in your browser as match with your exact value
I checked.In my opinion, there is only one problem that picture is in Views directory.I tried to put picture in Content directory,then it worked correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.