WebServiceHelper.TryUrlRedirection 方法

将 Web 服务对象重定向到 ASP.NET 开发服务器而不是提供的 Web 引用中定义的资源。

命名空间:  Microsoft.VisualStudio.TestTools.UnitTesting
程序集:  Microsoft.VisualStudio.QualityTools.UnitTestFramework(在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

语法

声明
Public Shared Function TryUrlRedirection ( _
    client As WebClientProtocol, _
    context As TestContext, _
    identifier As String _
) As Boolean
public static bool TryUrlRedirection(
    WebClientProtocol client,
    TestContext context,
    string identifier
)
public:
static bool TryUrlRedirection(
    WebClientProtocol^ client, 
    TestContext^ context, 
    String^ identifier
)
static member TryUrlRedirection : 
        client:WebClientProtocol * 
        context:TestContext * 
        identifier:string -> bool 
public static function TryUrlRedirection(
    client : WebClientProtocol, 
    context : TestContext, 
    identifier : String
) : boolean

参数

返回值

类型:System.Boolean
如果发生了重定向,则为 true;否则为 false。

备注

当使用 AspNetDevelopmentServerAttribute 运行测试时,将启动 ASP.NET 开发服务器的实例。 确保 ASP.NET 开发服务器站点启动并确保 URL为已知。 运行测试时,您可以使用 TryUrlRedirection 重定向 Web 服务对象,使它指向已知服务器,而不是提供的 Web 引用中定义的资源。 如果重定向未成功,则此方法将返回 true,如果重定向成功则将返回 false。 例如,如果该标识符与现有 ASP.NET Development Server 实例不匹配,则该方法返回 false。

.NET Framework 安全性

请参见

参考

WebServiceHelper 类

Microsoft.VisualStudio.TestTools.UnitTesting 命名空间

TestContext

AspNetDevelopmentServerAttribut