Friday, January 31, 2014

Error - A potentially dangerous Request.Path value was detected from the client

During calling REST service from client end i came across the below error..

"A potentially dangerous Request.Path value was detected from the client"

For this, i found following solution in web.config file of REST end and it works for me



- For httpruntime put requestpathinvalidcharacters="" & requestvalidationmode="2.0"
- For pages put validaterequest="false" 
- Both of these tags are located under configuration --> system.web

Also, there are some useful links too for this error
(1) Getting “A potentially dangerous Request.Path value was detected from the client (&)”

(2) A potentially dangerous Request.Path value was detected from the client (*)

Tuesday, January 28, 2014

Working with filtering JSON objects

Following are some way by which we can filter out objects in JSON format using jQuery.

(1) filter : using this method we can filter out JSON data by following way..
var filterData = (JSONDATA.filter(function (item) {
            return item["ColumnName"] != "Your Data To Compare";
        }));
- In above situation, filter will loop through each data and finds the specific data by comparing it.
- filter is only available in new version of jQuery. Also, it is not working in IE-8 and not compatible with IE-8 or lower.

(2) grep : using this method we can filter out JSON data by following way..
var filterData = ($.grep(JSONDATA,function (item,l) {
            return item["ColumnName"] != "Your Data To Compare";
        }));
In above situation, grep will loop through each data and finds the specific data by comparing it.


(3) slice : using this method we can removes and returns a given number of elements starting from a given index from JSON object by following way..
var filterData = $.each(JSONDATA.slice(1,3), function(item) {
                    return item;

                }),
- In above example, removes three elements starting from index position 1 (i.e., the 2nd, 3rd, and 4th elements) and returns them as an array.

- Find following link for the Grep vs Filter in jQuery.