views:

14

answers:

2

In JScript, why do I get the error "Object doesn't support this property or method" when I try to convert request.querystring to a string using toString()?

var params = Request.QueryString;

var params = params.toString();

Background info:

I'm trying to convert the querystring to a string so that I can perform a regex replace and remove certain items when they appear in the url.

var param = param.replace(/([?&])(allow)=[\w-]+/g, "");
A: 

I don't know -- weird Microsoft JScript implementation.

I had the same problem.

var strParams = new String(params);

seems to work though.

Jhong
A: 

I recently discovered the solution to this problem.

var params = Request.QueryString;

should be:

var params = Request.QueryString.Item;

There is no need to convert params to a string after that to manipulate the query string. Further you have access to everything in the query string by calling Request.QueryString("param").Item.

Example:

http://www.mysite.com?q=query&name=george

var name = Request.QueryString("name").Item;
George