[英]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()? 在JScript中,当我尝试使用toString()将request.querystring转换为字符串时,为什么会出现错误“对象不支持此属性或方法”?
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. 我正在尝试将querystring转换为字符串,以便我可以执行正则表达式替换并在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.
此外,您可以通过调用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. 我不知道-奇怪的Microsoft JScript实现。
I had the same problem. 我有同样的问题。
var strParams = new String(params);
seems to work though. 似乎工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.