开发者

how to stop asp.net from uploading posted file

I'm developing a httpHandler, in my source code if some conditions aren't met i would like to stop uploading file to th开发者_运维问答e server ( for example file extension is not allowed)

When I try to quit ProcessRequest function with return null;, asp.net tries and uploads the file automatically before I quit the httpHandler...

How can I stop asp.net to automatically upload posted files?

Here is the list of thing I've tested so far and no luck:

public void ProcessRequest(HttpContext context) {
    var worker = (HttpWorkerRequest)provider.GetService(typeof(HttpWorkerRequest));
    ..........
    worker.CloseConnection();
    context.Response.End();
    Environment.Exit(0);
    return null;
}


The issue you are having is that IIS fully uploads the file to a working location before your application is handed the request.

IIS asp.net mvc partial? file upload

If you truly want to control size and file type (extension) you will need to use an async upload process. I have had good luck with "uploadify".

http://www.uploadify.com/

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜