Handle HTTP Errors

4 posts, 0 answers
  1. Torben
    Torben avatar
    9 posts
    Member since:
    Sep 2012

    Posted 15 Mar 2013 Link to this post

    Hello Forum,
    we are using the RadAsyncUpload for an ImageUpload.
    I am currently working on the user friendliness of our application.
    When i change the name of for example a Message-File from "MyMessage.msg" to "MyMessage.png" it will pass through the validation but the Visual Studio shows a exception. For the user however its just like everything went well.
    Except it leads to problems later because the uploaded file is not really an Image...

    Is there any way to catch this error, so i can show an alert to the user?
  2. MasterChiefMasterChef
    MasterChiefMasterChef avatar
    152 posts
    Member since:
    Jan 2013

    Posted 15 Mar 2013 Link to this post

    Hi Torben,

    Hopefully Telerik does something internally to make sure that this name change will not pass validation. In the meantime, you can use two of the client-side events to make sure that the name wasn't changed by the user. You could use the OnClientFileSelected event to get the current file name (get_fileName parameter), and then after the OnClientFileUploading event fires you could compare the uploading file name with the selected file name. 

    Hopefully this helps,
    Master Chief
  3. Plamen
    Plamen avatar
    3080 posts

    Posted 19 Mar 2013 Link to this post

    Hello Torben,

     I have inspected the issue and when setting the AllowedFilesExtensions property as for example in this on-line demo after changing the extension of the file it was validated properly. You can then use the OnClientValidationFailed event as shown in this article.

    If your scenario is some how different please elaborate a little bit so we could be more helpful.

    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  4. Torben
    Torben avatar
    9 posts
    Member since:
    Sep 2012

    Posted 19 Mar 2013 Link to this post

    Thanks for your replys.
    The soluition im using now is as following:
    When the file is uploaded and i get to my Upload Handler i convert the file into an Image.
    So if the Validation suceeded but the File isn't an image the convewrsion will fail and a exception is thrown.
    The the Upload fails and i get into the OnFileUploadFailed method, where i can show the Error.
Back to Top