views:

284

answers:

3

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.

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.

Thanks!

EDIT:

I'm using ASP.NET MVC

A: 

In ASP.Net 2.0, a new FileUpload control was added that can be used to limit file types and sizes, among other things.

DOK
A: 

As far as I am aware, this isn't possible with stock .NET code, unless you spend time to recreate the file handling and parsing ASP.NET does.

plug

My SlickUpload component supports ASP.NET MVC and upload interception. You can create a file filter that is called before the upload starts and throw an exception to cancel the upload. It also includes error handling support so you can show the user a meaningful error message when this happens.

Post on the forums or contact me at chrish at krystalware dot com if you have any questions

Chris Hynes
A: 

This is really a job for a HttpModule, not a HttpHandler. Just check remote IP against a blacklist in the BeginRequest event and null route or what have you.

Wyatt Barnett