9

We're building an ASP.NET MVC 4 app in Visual Studio 2015. The app uses Elmah.MVC for exception handling. We're three developers; for two of us it's working fine on localhost, but one developer is getting this error (captured by Elmah):

The controller for path '/favicon.ico' was not found or does not implement IController.

This post provides a solution, and I've modified the routes to include it and the developer in question has synced his code:

routes.IgnoreRoute("{*favicon}", new { favicon = @"(.*/)?favicon.ico(/.*)?" });

Now nothing shows up in Elmah but the user continues to see a generic error:

500 - Internal server error.
There is a problem with the resource you are looking for, and it cannot be displayed.

What could be going on? Thanks.

Update 1: Ripped out the Elmah stuff from Web.config and just had the developer load the app. It gets into an infinite loop trying to authenticate the user, similar to this.

We're using OWIN-MixedAuth, and the issue is more than likely on the IIS Express settings. I'll have the developer try it tomorrow and confirm:

  1. Highlight the project in Visual Studio
  2. Open the 'Properties' panel on the right (or press F4)
  3. Set 'Windows Authentication' to 'Enabled'
  4. Set 'Anonymous Authentication' to 'Enabled'

As the name suggests, it's mixed auth, so both types of authentication have to be enabled.

Update 2: The OWIN-Mixed Auth issue has been fixed. Now, it has something to do with these three HTTP modules in Web.config used by Elmah:

<httpModules>
  <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
  <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
  <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
</httpModules>

When we comment them out, the one developer is able to get onto the site. What do these modules do? Why would they cause a problem?

Alex
  • 34,699
  • 13
  • 75
  • 158
  • 2
    Why not just add a favicon.ico for your site? – Darryl Braaten Jul 17 '17 at 20:18
  • 1
    That's the funny thing, @DarrylBraaten -- we have a favicon.ico! See my update above. – Alex Jul 17 '17 at 20:18
  • 1
    Ensure the one dev that is having issues has the `favicon.ico` file actually included in his solution. VS won't copy it over to the temp site during debug if the file is only present and not included – Tommy Jul 17 '17 at 21:59
  • As an aside: accessing `/favicon.ico` is a convention followed by a few browsers, so even if you have a favicon elsewhere and declared in your pages, you will still find this kind of entry in your logs. Same for `/apple-touch-icon.png`. – philippe_b Jul 18 '17 at 07:42

2 Answers2

3

Finally resolved the issue. We had to make two changes:

  • We're using OWIN-MixedAuth, and part of the issue was on the IIS Express settings (under "Development Server" section):

    1. Highlight the project in Visual Studio
    2. Open the 'Properties' panel on the right (or press F4)
    3. Set 'Windows Authentication' to 'Enabled'
    4. Set 'Anonymous Authentication' to 'Enabled'
  • Another part of the issue: a corrupted applicationhost.config file used by IIS Express:

    1. Ensure you're showing hidden files in Windows Explorer.
    2. Go to the root of your project via Windows Explorer.
    3. Open the hidden .vs folder.
    4. Go to config > applicationhost.config, make a backup, and open it in Notepad (Notepad++ is better).
    5. Compare it to a working applicationhost.config file from one of our machines. We found lots of old sites that were listed in the config file which were not being used anymore.
    6. Once cleaned up, launched the app and it worked.
Alex
  • 34,699
  • 13
  • 75
  • 158
1

Add this to your global.asax file.

routes.IgnoreRoute("favicon.ico");
Shahzad Khan
  • 432
  • 2
  • 14