title: How to prevent direct access to images in ASP.NET MVC?
body: <p>I need the same thing as this guy here:</p>
  
  <p><a href="http://forums.asp.net/t/1507682.aspx" rel="nofollow">http://forums.asp.net/t/1507682.aspx</a></p>
  
  <p>The thing is that the answer he marked as correct doesn't work for me. I am using ASP.NET MVC3 soon to be migrated to MVC4 and Windows Server 2012.
  I want to prevent direct access to some images because of security issues. It's not Image Leeching protection I'm worried at this moment, I read several articles on how to do that.</p>
  
  <p>If the link is on my page like this</p>
  
  <pre><code>&lt;img src="/Content/Images/img1.jpg" /&gt;
  </code></pre>
  
  <p>The image should be shown, but not if it is directly accessed:</p>
  
  <pre><code>http://mywebsite.com/Content/Images/img1.jpg
  </code></pre>
  
  <p>Since we're talking about images and several people accessing it, a solution that considers performance issue would be my way to go.</p>
  
  <p>Any ideas on how to implement that?</p>
  
  <p>Thanks.</p>