kaivalya
kaivalya

Reputation: 3869

MVC IgnoreRoute to ignore requests coming to a specific folder

My site is under the bombardment of some image requests for images that don't exist on my server. Seem to be porn related images that got nothing to do with my site.

Pattern is like this;

/loc208/th_e82_shower028.jpg

/loc171/th_251_shower014.jpg

/loc295/th_21e_shower052.jpg

so they all look under /loc* folder

Is there a way I write a script on my global.asax.cs file of my MVC application that would make the app ignore all these requests so that I don't flood my logs with "The controller for path '/loc295/th_21e_shower052.jpg' could not be found or it does not implement IController" message?

Upvotes: 0

Views: 814

Answers (1)

Craig Stuntz
Craig Stuntz

Reputation: 126577

Routing is the wrong solution here. By the time the request hits ASP.NET, it's already loading your server. You should configure the web server itself -- or, better still, an upstream security appliance -- to reject these.

One way to configure IIS would be to do an exclude on the folders in question. The request would no longer go to ASP.NET and would then 404. But like I said, it's better to do this upstream.

Upvotes: 1

Related Questions