Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an MVC application and my error handling is set up like this in web.config:

<customErrors mode="On" defaultRedirect="~/Error/" redirectMode="ResponseRedirect">
    <error statusCode="404" redirect="~/Error/NotFound/" />
</customErrors>

Every time a request for non existing image comes my NotFound action on Error controller is being hit, and I get an error The controller for path '/img/home/myimg.jpg' was not found or does not implement IController. logged.

I added RouteTable.Routes.IgnoreRoute("img/"); to my Global.asax but it doesn't help. How can I make MVC to ignore all requests to any files?

Thanks

share|improve this question
1  
Hey @Burjua, did you find a solution to this? I am having a similar issue with ASP.NET Forms.. –  Emin Dec 19 '12 at 10:37
1  
This should work for you: stackoverflow.com/questions/7333343/… If it doesn't, I suspsect that there is something wrong with your routing configuration, because request for files that actually exist on disk (js, images, css, etc) should never make it to the MVC routing system. –  jeff.eynon Jun 20 '13 at 14:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.