简体   繁体   中英

converting request.querystring using toString()

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, "");

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;

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

I had the same problem.

var strParams = new String(params);

seems to work though.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM