基于 Windows 的应用程序来测试我的 ASP.NET 应用程序
我想强调我的网站具有多种访问能力。为此,我创建了一个基于 Windows 的应用程序,该应用程序调用网站 1000 次。 不幸的是它只适用于 2 个电话。这是代码:
static void myMethod( int i)
{
int j = 0;
try
{
string url = "";
WebRequest wr = null;
HttpWebResponse response = null;
url = String.Format("http://www.google.com");
wr = WebRequest.Create(url);
//wr.Timeout = 1000;
response = (HttpWebResponse)wr.GetResponse();
MessageBox.Show("end");
}
catch (Exception ex)
{
MessageBox.Show(j.ToString() + " " + ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 1000; i++)
{
ThreadStart starter = delegate { myMethod(i); };
Thread thread = new Thread(starter);
thread.Start();
}
}
I want to stress my website with multiple access. To do that i created a windows based application that call 1000 times the website.
Unfortunatly it work just for 2 call. This is the code:
static void myMethod( int i)
{
int j = 0;
try
{
string url = "";
WebRequest wr = null;
HttpWebResponse response = null;
url = String.Format("http://www.google.com");
wr = WebRequest.Create(url);
//wr.Timeout = 1000;
response = (HttpWebResponse)wr.GetResponse();
MessageBox.Show("end");
}
catch (Exception ex)
{
MessageBox.Show(j.ToString() + " " + ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < 1000; i++)
{
ThreadStart starter = delegate { myMethod(i); };
Thread thread = new Thread(starter);
thread.Start();
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
而是使用 免费 WCAT 工具 用于加载测试您的 ASP.NET 页面。
另请观看此视频 [如何:] 对 Web 应用程序进行负载测试
如果您有 Visual Studio 2010 Ultimate,请参阅此链接
我希望这有帮助。
Rather use the Free WCAT Tool to load test your ASP.NET page.
Also view this video [How Do I:] Load Test a Web Application
If you have Visual Studio 2010 Ultimate, see this link
I hope this helps.
默认情况下,
HttpRequest
仅允许到同一主机的两个连接。您可以通过设置 DefaultConnectionLimit 属性来更改此设置。
By default
HttpRequest
only allows two connections to the same host.You can change this by setting the DefaultConnectionLimit property.
在继续之前尝试处理
IDisposable
实例(即响应)。Try disposing the
IDisposable
instances (i.e. the response) before continuing.