Visual Studioの負荷テストツールを使用してWebページの負荷テストを行っていますが、結果の表示に問題があります。問題はCookieなしのセッションです。新しいユーザーがページにアクセスするたびに、ページのURLが変更され、平均ページ応答時間を計算できません。それについて何ができるでしょうか?
1 に答える
0
Cookieをクエリ文字列に移動しました。
その前に、URLのセッションコンポーネントを無視する大文字と小文字を区別しないURL検証イベントハンドラーを作成しました。以下のものは、大文字と小文字の区別のみを削除します。
class QueryLessCaseInsensitiveValidateResponseUrl : ValidateResponseUrl
{
public override void Validate(object sender, ValidationEventArgs e)
{
Uri uri;
string uriString = string.IsNullOrEmpty(e.Request.ExpectedResponseUrl) ? e.Request.Url : e.Request.ExpectedResponseUrl;
if (!Uri.TryCreate(e.Request.Url, UriKind.Absolute, out uri))
{
e.Message = "The request URL could not be parsed";
e.IsValid = false;
}
else
{
Uri uri2;
string leftPart = uri.GetLeftPart(UriPartial.Path);
if (!Uri.TryCreate(uriString, UriKind.Absolute, out uri2))
{
e.Message = "The request URL could not be parsed";
e.IsValid = false;
}
else
{
uriString = uri2.GetLeftPart(UriPartial.Path);
////this removes the query string
//uriString.Substring(0, uriString.Length - uri2.Query.Length);
Uri uritemp = new Uri(uriString);
if (uritemp.Query.Length > 0)
{
string fred = "There is a problem";
}
//changed to ignore case
if (string.Equals(leftPart, uriString, StringComparison.OrdinalIgnoreCase))
{
e.IsValid = true;
}
else
{
e.Message = string.Format("The value of the ExpectedResponseUrl property '{0}' does not equal the actual response URL '{1}'. QueryString parameters were ignored.", new object[] { uriString, leftPart });
e.IsValid = false;
}
}
}
}
}
によって呼び出されます
public EventHandler<ValidationEventArgs> AddUrlValidationEventHandler(WebTestContext context, WebTest webTest)
{
EventHandler<ValidationEventArgs> urlValidationRuleEventHandler = null;
// Initialize validation rules that apply to all requests in the WebTest
if ((context.ValidationLevel >= Microsoft.VisualStudio.TestTools.WebTesting.ValidationLevel.Low))
{
QueryLessCaseInsensitiveValidateResponseUrl validationRule1 = new QueryLessCaseInsensitiveValidateResponseUrl();
urlValidationRuleEventHandler = new EventHandler<ValidationEventArgs>(validationRule1.Validate);
webTest.ValidateResponse += urlValidationRuleEventHandler;
}
return urlValidationRuleEventHandler;
}
今私がする必要があるのは追加することだけです
//add case insensitive url validation for all requests
urlValidationRuleEventHandler = common.AddUrlValidationEventHandler(this.Context, this);
大文字と小文字を区別しない呼び出しを取得するためのWebテストに。このコードには次の不適切な行が含まれていることに注意してください
string fred = "There is a problem";
于 2010-03-07T23:23:22.790 に答える