为 mvc 站点查询字符串创建 webtest 提取规则

发布于 2025-01-07 12:51:53 字数 747 浏览 0 评论 0原文

谁能告诉我如何创建允许我从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烦人精 2025-01-14 12:51:53

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文