My project implements search (from default HTML
page) and will redirect to the search page (ASPX
page) and I'm using query string to pass the search value. I'm getting potentially dangerous Request.QueryString value
server error when language is set to non-english (e.g. thai, cyrillic).
Is there any way to handle this from client side? Currently I can't find a way to handle this from the page itself (Page_Load
, Page_PreInit
isn't triggering).
Here's the code I used for redirecting:
function Search() {
var searchString = document.getElementById('txtSearch').value;
location.href = "/Search.aspx?search=" + searchString;
}
Adding validateRequest="false"
to you .Net Page or Web.config file
OR
you can encode your url vars, adding encodeURIComponent
:
function Search() {
var searchString = document.getElementById('txtSearch').value;
location.href = "/Search.aspx?search=" + encodeURIComponent(searchString);
}