2013-12-09 106 views
1

我需要在webBrowser控件發送請求後捕獲響應內容。從webBrowser控件捕獲httpresponse對象

當我運行httpAnalyzer時,我能夠捕獲response content中傳回給webBrowser控件的一些重要數據(原始數據)。

任何想法?

更多信息: 我有一個內部網站,它使用閃光燈生成報告。我能夠自動加載頁面並模擬生成報告的按鈕單擊。當我使用httpAnalyzer時,我能夠看到我需要捕獲的原始數據;但我不知道如何實際得到響應對象。

+0

看看FiddlerCore http://fiddler2.com/fiddlercore – volody

回答

0

我用FiddlerCore:http://fiddler2.com/fiddlercore

private void button_click() 
    { 
     Thread myThread = new Thread(delegate() 
     { 
      fiddlerRun(); 
     }); 
     myThread.Start(); 
    } 

    private void fiddlerRun() 
    { 
     #region AttachEventListeners 
     Fiddler.FiddlerApplication.BeforeResponse += delegate(Fiddler.Session oS) 
     { 
      String s1 = oS.GetResponseBodyAsString(); // this is where response is catched 
      //I know that response must contain specific word - if it is there- catch it! 
      if (s1.Contains("License")) 
      { 
       //do my stuff with response 
       //... 
       //stop Fiddler 
       Fiddler.FiddlerApplication.Shutdown(); 
       System.Threading.Thread.Sleep(750); 
      } 
     }; 
     #endregion AttachEventListeners 
     System.Diagnostics.Debug.WriteLine("Starting FiddlerCore..."); 
     Fiddler.CONFIG.IgnoreServerCertErrors = false; 
     try 
     { 
      Fiddler.FiddlerApplication.Startup(8877, true, true); 
     } 
     catch { } 
    }