The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WebServiceHelper.TryUrlRedirection Method (WebClientProtocol, TestContext, String)


Redirects a Web service object to the ASP.NET Development Server instead of the resource that is defined in the provided 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


Type: System.Web.Services.Protocols.WebClientProtocol

An instance of the Web service type that is being tested.

Type: Microsoft.VisualStudio.TestTools.UnitTesting.TestContext

The TestContext for this unit test.

Type: System.String

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

Type: System.Boolean

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 makes sure 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 the resource that is defined in the provided 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, the method returns false.

WebServiceHelper Class
Microsoft.VisualStudio.TestTools.UnitTesting Namespace

Return to top