all things Sitecore related

Asp.Net: Webtest trough proxy (WebTestPlugin)

By on October 24, 2010 in ASP.Net, Microsoft, Visual Studio with 0 Comments

The test-team came to me with a problem involving connection errors while running webtests trough the company proxy. The webrequest needed to go to the webproxy including authentication. Visual Studion 2008 doesn’t support proxy authentication out of the box, but you can create a WebTestPlugin that does the authentication for every request.

The following class inherits from WebTestPlugin and overrides the PreWebTest method. In the PreWebTest method it will authenticate the request with your credentials.

public class LoadTestProxyAuthentication : WebTestPlugin
        public override void PreWebTest(object sender, PreWebTestEventArgs e)
            // Create WebProxy (enter your proxy url)
            WebProxy webProxy = new WebProxy("ProxyAdres");

            // Use the proxy for the webtest
            e.WebTest.WebProxy = webProxy;

            e.WebTest.PreAuthenticate = true;
            NetworkCredential proxyCredentials;

            proxyCredentials = new NetworkCredential();

            proxyCredentials.Domain = "domain";
            proxyCredentials.UserName = "username";
            proxyCredentials.Password = "password";
            e.WebTest.WebProxy.Credentials = proxyCredentials;

How to use the webtestplugin
Ad the class to your test project, change the credentials and proxyadres. After a build open the webtest press the ‘add  Webtest plugin’ button (on the top screenmenu), select the LoadTestProxyAuthentication and press OK. You need to add the webtestplugin for every webtest.

Now you can run your webtests trough the proxy.

Hope it helps,

Tags: , ,

About the Author

About the Author: Pieter is Technical Marketing Manager for Sitecore Netherlands and owner of He has more than ten years experience with software developing in multiple programming languages and with different Content Management Systems. Before joining Sitecore Pieter was a lead developer for multiple Sitecore and .Net projects, he joined Sitecore in 2011 as an Solution Architect in The Netherlands, after two years as an Solution Architect he joined the Technical Marketing department. In the role as Techinical Marketing Manager he is responsible for the Global MVP program and the Sitecore technical branding strategy. You can follow Pieter on twitter: @pieterbrink123 or Google+ .


If you enjoyed this article, subscribe now to receive more just like it.

Post a Comment

Your email address will not be published. Required fields are marked *