Skip to content Skip to sidebar Skip to footer

What's The Best Way To Get Round A 'potentially Dangerous Request' Error In Asp.net?

The project I am currently working on has, in the checkout, an option to attach an embedded YouTube video to an advert. This is causing a headache: My original plan was to take the

Solution 1:

Turning off the ValidateRequest flag is the only way to allow for .net to accept the data.

One alternative may be to use javascript to encode the input and have the page post the encoded data instead of the raw html.

Another alternative is to have a blank page with your control and a "submit" button within an iframe on the main page. That way you only need to turn off validation for that page and therefore that control. Styling can be an issue here though.

Solution 2:

If you are only interested in the video ID from YouTube, could you not just get the user to enter the YouTube URL then extract the video ID from the querystring? Then you wouldn't have to worry about the page validation issues at all.

Post a Comment for "What's The Best Way To Get Round A 'potentially Dangerous Request' Error In Asp.net?"