简体   繁体   English

基于Windows的应用程序来测试我的ASP.NET应用程序

[英]Windows based application to test my ASP.NET application

I want to stress my website with multiple access. 我想通过多次访问来强调我的网站。 To do that i created a windows based application that call 1000 times the website. 为此,我创建了一个基于Windows的应用程序,该应用程序调用了1000次网站。 Unfortunatly it work just for 2 call. 不幸的是,它仅适用于2个通话。 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();               
        }

    }

Rather use the Free WCAT Tool to load test your ASP.NET page. 而是使用免费的WCAT工具对您的ASP.NET页进行负载测试。

Also view this video [How Do I:] Load Test a Web Application 另请观看此视频[如何:]负载测试Web应用程序

If you have Visual Studio 2010 Ultimate, see this link 如果您拥有Visual Studio 2010 Ultimate,请参阅此链接

I hope this helps. 我希望这有帮助。

By default HttpRequest only allows two connections to the same host. 默认情况下, HttpRequest仅允许到同一主机的两个连接。 You can change this by setting the DefaultConnectionLimit property. 您可以通过设置DefaultConnectionLimit属性来更改此设置。

Try disposing the IDisposable instances (ie the response) before continuing. 在继续之前,请尝试处置IDisposable实例(即响应)。

static void myMethod( int i)
{
    int j = 0;

    try
    {

        string url = String.Format("http://www.google.com");
        WebRequest wr = WebRequest.Create(url);
        using(HttpWebResponse response = (HttpWebResponse)wr.GetResponse())
        using(Stream responseStream = wr.GetResponseStream())
        {
            //handle response / response stream
        }                
        MessageBox.Show("end");  //this won't scale!!!
    }
    catch (Exception ex)
    {
        MessageBox.Show(j.ToString() + "   " + ex.Message);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM