简体   繁体   English

MVC IgnoreRoute忽略进入特定文件夹的请求

[英]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 /loc208/th_e82_shower028.jpg

/loc171/th_251_shower014.jpg /loc171/th_251_shower014.jpg

/loc295/th_21e_shower052.jpg /loc295/th_21e_shower052.jpg

so they all look under /loc* folder 所以它们都在/ loc *文件夹下

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? 有没有一种方法可以在我的MVC应用程序的global.asax.cs文件中编写脚本,该脚本将使该应用程序忽略所有这些请求,以免我的日志中没有显示“路径'/ loc295 / th_21e_shower052的控制器”。找不到jpg”或未实现IController”消息?

Routing is the wrong solution here. 路由是错误的解决方案。 By the time the request hits ASP.NET, it's already loading your server. 在请求到达ASP.NET时,它已经在加载服务器。 You should configure the web server itself -- or, better still, an upstream security appliance -- to reject these. 您应该配置Web服务器本身-或者更好的是,上游安全设备-拒绝这些。

One way to configure IIS would be to do an exclude on the folders in question . 一种配置IIS的方法是对相关文件夹进行排除 The request would no longer go to ASP.NET and would then 404. But like I said, it's better to do this upstream. 该请求将不再发送到ASP.NET,然后是404。但是就像我说的那样,最好在上游进行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM