Re: Anyway to bypass the UploadHandler.ashx completely?

  •  01-11-2011, 9:12 PM

    Re: Anyway to bypass the UploadHandler.ashx completely?

    Hi,
     
    You can bypass the UploadHandler.ashx , but mvc uploader still need a url to handle the stream and validate the uploaded file.
     
    The upload handler code is simple , you can implement your self  .
     
    And change the uploader.UploadUrl to your handler url or just your controller.
     
     
      void IHttpHandler.ProcessRequest (HttpContext context)
      {
       using (_uploader = new MvcUploader(context))
       {
        UploaderValidateOption option=this.GetValidateOption();
        _uploader.MaxSizeKB=option.MaxSizeKB;
        _uploader.AllowedFileExtensions=option.AllowedFileExtensions;
        OnUploaderInit(_uploader);
       
        _uploader.PreProcessRequest();
        if (!_uploader.IsValidationRequest)
         return;
        
        try
        {
         _file = _uploader.GetValidatingFile();
        
         OnFileUploaded(_file);
        }
        catch(Exception x)
        {
         _uploader.WriteValidationError(x.Message,_data);
         return;
        }
        
        _uploader.WriteValidationOK(_data);
       }
      }
     
     
    the core thing is PreProcessRequest,WriteValidationError,WriteValidationOK
     
     
    Regards,
    Terry
     
     
     
View Complete Thread