Monday, April 11, 2011

ASP.NET MVC Unhandled Exceptions on Images?

I haven't been able to replicate the exception when I browse my site... but I found out about this through my event logger (it emails my cell phone when an unhandled exception occurs).

Here's the exception:

The controller for path '/Content/UsrImg/ImageFileName.jpg' could not be found or it does not implement IController.

What I think happened is that the image that Google (or perhaps a proxy server) had cached no longer existed. When trying to go directly to that image, it load the "Page not found" friendly error I wrote.

But should it be throwing an unhandled exception on 404 errors? Seems a bit strange to me. Perhaps there something I can do in the routing to fix this?

From stackoverflow
  • I just ran into this issue yesterday. Check to see if the image is on your server. My problem was Build Action for the file was set to none, but it should be set to Content. It was not including the file when I published the website.

    You don't need to change routing, as the Content directory should be invoke Routing.

0 comments:

Post a Comment