Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

WebServiceHelper.TryUrlRedirection Method

Redirects a Web service object to the ASP.NET Development Server instead of what is defined in the Web reference.

Namespace: Microsoft.VisualStudio.TestTools.UnitTesting
Assembly: Microsoft.VisualStudio.QualityTools.UnitTestFramework (in microsoft.visualstudio.qualitytools.unittestframework.dll)

public static bool TryUrlRedirection (
	WebClientProtocol client,
	TestContext context,
	string identifier
public static boolean TryUrlRedirection (
	WebClientProtocol client, 
	TestContext context, 
	String identifier
public static function TryUrlRedirection (
	client : WebClientProtocol, 
	context : TestContext, 
	identifier : String
) : boolean



An instance of the Web service type being tested.


The TestContext for this unit test.


A unique string that identifies an ASP.NET Development Server instance. This matches the name parameter of an AspNetDevelopmentServerAttribute on the test method.

Return Value

true if a redirect occurred; otherwise, false.

When you run a test with an AspNetDevelopmentServerAttribute, an instance of an ASP.NET Development Server is started. This ensures that an ASP.NET Development Server site is started and that you know the URL. When you run a test, you can then use TryUrlRedirection to redirect a Web service object so that it points to the known server instead of what is defined in the Web reference. This method returns true if the redirection was successful, and false if it was not, for example, if the identifier did not match the name of an existing ASP.NET Development Server instance.

Community Additions

© 2015 Microsoft