简体   繁体   English

我可以拦截通过HTTP上传到IIS7的文件,并根据验证条件拒绝上传吗?

[英]Can I intercept a file upload over HTTP to IIS7 and deny the upload based on a validation criteria?

I have a form which you can post a file over to my server. 我有一个表格,您可以将文件发布到我的服务器上。

Is there a way, without using a custom HTTP handler, to intercept the start of the post and prevent it before the file is uploaded and bandwidth used up. 有没有一种方法,无需使用自定义HTTP处理程序,就可以拦截帖子的开头,并在文件上传和带宽耗尽之前阻止帖子的开始。

So for example, I could check an IP address and if it's blocked in my system I could stop the request before I waste 10MB of uploading. 因此,例如,我可以检查一个IP地址,如果该地址在系统中被阻止,则可以在浪费10MB的上传资源之前停止该请求。

Thanks! 谢谢!

EDIT: 编辑:

I'm using ASP.NET MVC 我正在使用ASP.NET MVC

据我所知,使用股票.NET代码是不可能的,除非您花时间重新创建文件处理并解析ASP.NET。

This is really a job for a HttpModule, not a HttpHandler. 对于HttpModule,而不是HttpHandler,这确实是一项工作。 Just check remote IP against a blacklist in the BeginRequest event and null route or what have you. 只需针对BeginRequest事件中的黑名单检查远程IP,然后将其设为空路由或您拥有什么。

在ASP.Net 2.0中,添加了一个新的FileUpload控件 ,该控件可用于限制文件类型和大小等。

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

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