Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'The controller for path '/favicon.ico' was not found...' error

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?

like image 205
Alex Avatar asked Jul 17 '17 19:07

Alex


2 Answers

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.
like image 115
Alex Avatar answered Oct 14 '22 09:10

Alex


Add this to your global.asax file.

routes.IgnoreRoute("favicon.ico");
like image 22
Shahzad Khan Avatar answered Oct 14 '22 09:10

Shahzad Khan