在用loadrunner对.net编写的website进行性能测试时,经常会遇上一些hidden fields,例如,CSRFTOKEN、VIEWSTATE、EVENTVALIDATION等,而对于这些hidden field,有时候需要进行前后关联。但是最近发现一个很奇怪的现象:已经通过web_reg_save_param_regexp函数准确的获取了这些hidden fields,并且所得的param在web_submit_data可以正常使用,但是用在web_custom_request时却总是报错,百思不得其解!经过google后终于弄明白了:

进行关联通常用到的都是web_reg_save_param、web_reg_save_param_ex、web_reg_save_param_regexp这三个函数,需要注意的是这三个函数拿回来的param的值都是html编码的。

对于html编码的param,web_submit_data函数可以直接使用,但是web_custom_request则不可以直接使用,而需要通过函数web_convert_param先转换为url编码才可以,否则是会产生error的。

int web_convert_param( const char *ParamName, [char *SourceString] char *SourceEncoding, char *TargetEncoding, LAST );

Example 1

The following example uses web_convert_param to convert HTML strings to URL and plain text formats.

The Web page has these texts:

Sample HTML code to be converted: <mytag>& End

Sample plain text to be converted: 1–AD X=0+2 End

Action()

{

web_reg_save_param("HTML",

"LB=Sample HTML code to be converted: ",

"RB= End",

LAST );

web_reg_save_param("HTML1",

"LB=Sample HTML code to be converted: ",

"RB= End",

LAST );

web_reg_save_param("Plaintext",

"LB=Sample plain text to be converted: ",

"RB= End",

LAST );

web_url("web_url",

"URL=http://lazyboy/html/convert_param_page.html",

"TargetFrame=",

"Resource=0",

"Referer=",

LAST );

web_convert_param("HTML", "SourceEncoding=HTML",

"TargetEncoding=URL", LAST );

web_convert_param("HTML1", "SourceEncoding=HTML",

"TargetEncoding=PLAIN", LAST );

web_convert_param("Plaintext", "SourceEncoding=HTML",

"TargetEncoding=URL", LAST );

web_reg_save_param("Result",

"LB=<code>entry = ",

"RB=</code>",

LAST );

web_custom_request("web_custom_request",

"URL=http://lazarus/cgi–bin/post_query.exe",

"Method=POST",

"TargetFrame=",

"Resource=0",

"Referer=",

"Body=entry={Plaintext},{HTML}",

LAST );

return 0;

}

The following section shows the relevant sections of the log file that resulted from running the above segment:

Running Vuser...

Action.c(21): Saving Parameter "HTML = &lt;mytag&gt;&amp;"

Action.c(21): Saving Parameter "HTML1 = &lt;mytag&gt;&amp;"

Action.c(21): Saving Parameter "Plaintext = 1–AD X=0+2"

After web_url:

Action.c(28): Saving Parameter "HTML = %3Cmytag%3E%26"

Action.c(28): web_convert_param was successful

Action.c(29): Saving Parameter "HTML1 = <mytag>&"

Action.c(29): web_convert_param was successful

Action.c(30): Saving Parameter "Plaintext = 1–AD+X%3D0%2B2"

Action.c(30): web_convert_param was successful

web_custom_request:

Action.c(37): Parameter Substitution: parameter "Plaintext" = "1–AD+X%3D0%2B2"

Action.c(37): Parameter Substitution: parameter "HTML" = "%3Cmytag%3E%26"

Action.c(37): Saving Parameter "Result = 1–AD X=0+2,<mytag>&"

Example 2

This example shows the use of the SourceString argument. Note that the source string can contain parameters. The source string is first evaluated, replacing parameters with their values, then converted to PLAIN. The result is stored in parameter "targetParam."

web_convert_param(

"targetParam",

"SourceString={param1}abc{param2}",

"SourceEncoding=HTML",

"TargetEncoding=PLAIN",

LAST );

[原创] web_custom_request 与 Viewstate的更多相关文章

  1. ASP.NET保存信息总结(Application、Session、Cookie、ViewState和Cache等) ZT

    http://www.cnblogs.com/ranran/p/4065619.html http://www.cnblogs.com/jxlsomnus/p/4450911.html 以下是关于AS ...

  2. [ASP.net教程]ASP.NET保存信息总结(Application、Session、Cookie、ViewState和Cache等)

    以下是关于ASP.NET中保存各种信息的对象的比较,理解这些对象的原理,对制作完善的程序来说是相当有必要的(摘至互联网,并非原创--xukunping)在ASP.NET中,有很多种保存信息的对象.例如 ...

  3. 转:web_custom_request 和 web_submit_data的差别

    web_custom_request方法可以发送POST和GET类型的请求 web_submit_data只能发送POST类型的请求 所有web_submit_data方法发送的请求都可以使用web_ ...

  4. ASP.NET保存信息总结(Application、Session、Cookie、ViewState和Cache等)

    以下是关于ASP.NET中保存各种信息的对象的比较,理解这些对象的原理,对制作完善的程序来说是相当有必要的(摘至互联网,并非原创--xukunping) 在ASP.NET中,有很多种保存信息的对象.例 ...

  5. web_custom_request和web_submit_data

    网络上很多说明这2个函数区别的文章,我就从其他摘抄了内容,其中区别自己查看附录,我主要说明2点 (1)用web_custom_request提交请求如果是json,则会会使用关键字符{},但是{},是 ...

  6. 【原创分享·支付宝支付】HBuilder打包APP调用支付宝客户端支付

    前言 最近有点空余时间,所以,就研究了一下APP支付.前面很早就搞完APP的微信支付了,但是由于时间上和应用上的情况,支付宝一直没空去研究.然后等我空了的时候,发现支付宝居然升级了支付逻辑,虽然目前还 ...

  7. 【原创分享·微信支付】C# MVC 微信支付教程系列之现金红包

            微信支付教程系列之现金红包           最近最弄这个微信支付的功能,然后扫码.公众号支付,这些都做了,闲着无聊,就看了看微信支付的其他功能,发现还有一个叫“现金红包”的玩意,想 ...

  8. 【原创分享·微信支付】 C# MVC 微信支付教程系列之扫码支付

    微信支付教程系列之扫码支付                  今天,我们来一起探讨一下这个微信扫码支付.何为扫码支付呢?这里面,扫的码就是二维码了,就是我们经常扫一扫的那种二维码图片,例如,我们自己添 ...

  9. 【原创分享·微信支付】 C# MVC 微信支付教程系列之公众号支付

    微信支付教程系列之公众号支付         今天,我们接着讲微信支付的系列教程,前面,我们讲了这个微信红包和扫码支付.现在,我们讲讲这个公众号支付.公众号支付的应用环境常见的用户通过公众号,然后再通 ...

随机推荐

  1. webpy 开发环境搭建问题之Mysql-python安装

    关于python核心编程已经看了差不多,准备搞些框架方面的学习,本来想打算看看Django的,但是朋友推荐先看看轻量级的flask或者webpy的开发,所以晚上回来,搭建下开发环境(PS:搭建过程中由 ...

  2. LeadTools答题卡识别方案

    /// <summary> /// 批改操作 /// </summary> public AnswerCard DoCorrect(Stream AnserCardFile) ...

  3. erlang dets

    1.dets表包含set.bag.和duplicate bag 2.dets:open_file(TableName,Options)创建或打开表 3.Options 1){auto_save,Int ...

  4. Zookeeper 启动错误

    启动后日志如下 : 2016-09-14 05:51:19,449 [myid:1] - INFO [QuorumPeer[myid=1]/0:0:0:0:0:0:0:0:2181:FastLeade ...

  5. 导hive表项目总结(未完待续)

    shell里面对日期的操作 #!/bin/bash THIS_FROM=$(date +%Y%m%d -d "-7 day") THIS_TO=$(date +%Y-%m-%d - ...

  6. Tennis Championship

    Tennis Championship time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  7. laravel安装 笔记

    http://laod.cn/hosts/2015-google-hosts.html 谷歌FQIP laravel安装和设置流程 1安装composer , VirtualBox和Vagrant 下 ...

  8. linux安装文件命令

    tar -zxvf apache-tomcat.tar.gz -C /home/poka 注:安装tar.gz的安装包 设置系统自动启动tomcat 切换到root用户,执行命令 #chkconfig ...

  9. 将dom4j格式化为标准的xml字符串

    StringWriter writer = new StringWriter(); OutputFormat format = OutputFormat.createPrettyPrint(); fo ...

  10. Chapter 1 First Sight——28

    "Which one is the boy with the reddish brown hair?" 那个红褐色头发的男孩是谁? I asked. I peeked at him ...