How to reference an image tag

I'm studying Asp.Net MVC and I'm having trouble setting the URL of the tag

HTML:

      <!-- menu profile quick info -->
            <div class="profile">
                <div class="profile_pic">
                    <img src="~/Views/Home/images/img.jpg" alt="..." class="img-circle profile_img">
                </div>
                <div class="profile_info">
                    <span>Welcome,</span>
                    <h2>John Doe</h2>
                </div>
            </div>

My doubt is, Is this right this URL: src="~/Views/Home/images/img.jpg"?

My project hierarchy:

insert the description of the image here

Because when executing, I am having the error:

insert the description of the image here

Author: LINQ, 2016-10-27

1 answers

You may have already noticed that inside the Folder views there is a file web.config .

By default, this config restricts access to all files in this folder.

<httpHandlers>
  <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>
</httpHandlers>

For sure you can change that, but it doesn't make sense. You can end up allowing anyone (good or bad) to have access to the views files.

The tip I give you is to put your images in subfolders in the Folder content, and use them with the path ~ / Content/Images/home / img1.png . Of course you have the option to create other folders as well, but I think that Content already serves that.

 1
Author: LINQ, 2016-10-27 11:17:10