0

I am writing a .Net MVC website, and using IIS express.

How do Is stop images from being served up through the .Net pipeline. I appricate I can ignore the route by doing this: routes.IgnoreRoute("favicon.ico"). But I don't want the code to be hit at all.

I tried adding this to the system.webServer section in the web.config

<handlers>
   <add name="StaticFile-ico" path="*.ico" verb="*" modules="StaticFileModule" resourceType="File" requireAccess="Read" />
</handlers>

But this has no effect. What am I doing wrong?

Dan
  • 29,100
  • 43
  • 148
  • 207
  • duplicate of: http://stackoverflow.com/questions/6279643/prevent-iis-from-serving-static-files-through-asp-net-pipeline – Adam Tuliper Mar 07 '12 at 18:48
  • I don't think it is `runAllManagedModulesForAllRequests` is set to `false`. And I'm not sure .ico is included in the set of ignored extensions? – Dan Mar 08 '12 at 17:06

2 Answers2

0

This thread is quite old, but I had this same problem on an Azure website. I found a way to tell IIS to ignore /favicon.ico requests, as my favicon.ico is set using meta tags.

You just need to add a route and tell IIS to ignore the request:

<rule name="block favicon" stopProcessing="true">
  <match url="favicon\.ico" />
  <action type="CustomResponse" statusCode="404" subStatusCode="1" 
    statusReason="The requested file favicon.ico was not found" 
      statusDescription="The requested file favicon.ico was not found" />
</rule>
Poli
  • 2,514
  • 2
  • 18
  • 12
0

From: http://blogs.msdn.com/b/tmarq/archive/2010/04/01/asp-net-4-0-enables-routing-of-extensionless-urls-without-impacting-static-requests.aspx

On IIS 7 it's only the first couple requests to the static file that miss the kernel cache, assuming the request meets kernel caching requirements.

However since you've used iis express you will not get kernel caching, its not supported in iis express.

Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71