为 mvc 站点查询字符串创建 webtest 提取规则
谁能告诉我如何创建允许我从 MVC 查询字符串中提取 ID 的提取规则?
场景:
User hits site, and clicks "Add new"
Request: www.site.com/item/create
Response: www.site.com/item/view/2143
网站将立即创建一个新项目并将其重定向到查看项目页面。我想在 item/view/#### 之后的响应中提取 id
当前记录的 webtest 代码:
var request4 = new WebTestRequest((Context["WebServerAddress"] + "/Item/Create"));
request4.Method = "POST";
var request4Body = new FormPostHttpBody();
request4.Body = request4Body;
yield return request4;
request4 = null;
//server redirect response happens now
var request5 =
new WebTestRequest((Context["WebServerAddress"] + "/Item/Edit/?needIdForHere"));
yield return request5;
request5 = null;
有什么想法吗?
非常感谢,
科汉
Can anyone tell me how to create an extraction rule that will allow me to pull an ID from an MVC querystring?
Scenario:
User hits site, and clicks "Add new"
Request: www.site.com/item/create
Response: www.site.com/item/view/2143
The site will instantly create a new item and redirect them to the viewitem page. The id i would like to extract lives within the response after item/view/####
Current recorded code for webtest:
var request4 = new WebTestRequest((Context["WebServerAddress"] + "/Item/Create"));
request4.Method = "POST";
var request4Body = new FormPostHttpBody();
request4.Body = request4Body;
yield return request4;
request4 = null;
//server redirect response happens now
var request5 =
new WebTestRequest((Context["WebServerAddress"] + "/Item/Edit/?needIdForHere"));
yield return request5;
request5 = null;
Any ideas?
Many thanks,
Kohan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从
WebTestContext.LastResponse.ResponseUri
设置值可能会更有效,因为提取规则是为迭代响应正文而设计的。you may get more mileage setting the value from the
WebTestContext.LastResponse.ResponseUri
as an extraction rule is designed for iterating over the response body.