Thursday 17 October 2013

Potentially dangerous request in asp.net

Error:
JavaScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500

Solution:

you have to use the below function to decode the html tags before saving in DB

function encodeMyHtml(encodedHtml)
{
     encodedHtml = escape(encodedHtml);
     encodedHtml = encodedHtml.replace(/\//g, "%2F");
     encodedHtml = encodedHtml.replace(/\?/g, "%3F");
     encodedHtml = encodedHtml.replace(/=/g, "%3D");
     encodedHtml = encodedHtml.replace(/&/g, "%26");
     encodedHtml = encodedHtml.replace(/@/g, "%40");
     return encodedHtml;
}


1 comment: