When working with the ASP.NET 3.5 platform, I encountered an issue while using a file upload control and an ASP button to upload files that contain special characters, such as (file#&%.txt). This caused the application to crash and display the following message:
--------------------------------------------------------------------------------
Server Error in 'myapplication' Application.
--------------------------------------------------------------------------------
A potentially dangerous Request.Files value was detected from the client
(filename="...\New Text &#.txt").
Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.
Exception Details: System.Web.HttpRequestValidationException: A potentially dangerous Request.Files value was detected from the client
(filename="...\New Text &#.txt").
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
--------------------------------------------------------------------------------
Is there a way to prevent this crash using JavaScript on the client side?