How to reference an image tag img

0

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

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 question is, is this URL right: src="~/Views/Home/images/img.jpg" ?

My project hierarchy:

Well,whenIrun,I'mhavingtheerror:

    
asked by anonymous 27.10.2016 / 13:04

1 answer

1

You may have noticed that within the Views folder there is a web.config file.

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

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

Surely you can change that, but it does not make sense. You may end up allowing anyone (well or poorly engaged) to access the Views files.

The tip I give you is to put your images in subfolders in the Content folder, and use them with the ~ / Content / Images / Home / img1.png . Of course you have the option to create other folders as well, but I think Content already works for it.

    
27.10.2016 / 13:13