共用方式為


TestContext.AspNetDevelopmentServerPrefix 欄位

表示 ASP.NET 程式開發伺服器 (Development Server) 的前置詞。

命名空間:  Microsoft.VisualStudio.TestTools.UnitTesting
組件:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (在 Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll 中)

語法

'宣告
Public Const AspNetDevelopmentServerPrefix As String
public const string AspNetDevelopmentServerPrefix
public:
literal String^ AspNetDevelopmentServerPrefix
static val mutable AspNetDevelopmentServerPrefix: string
public const var AspNetDevelopmentServerPrefix : String

備註

這個常數的值為 "AspNetDevelopmentServer"。

在大多數情況下,您不會直接使用這個字串,因為您可以使用 TryUrlRedirection 方法將 Web 服務呼叫導向正確的 URL。

如果您想要取得 ASP.NET 程式開發伺服器執行個體 (因為在測試時指定 AspNetDevelopmentServerAttribute 而啟動的) 的 URL 前置詞,那麼就需要使用這個字串。 請將這個字串與 AspNetDevelopmentServerAttribute 中所指定的名稱搭配使用。 如需詳細資訊,請參閱以下程式碼片段:

範例

[TestMethod]
[AspNetDevelopmentServerAttribute("MyServer", @"c:\websites\website1", "/website1")]
public void Test()
{
    Uri uriPrefix = TestContext.Properties[TestContext.AspNetDevelopmentServerPrefix + "MyServer"];
}

.NET Framework 安全性

請參閱

參考

TestContext 類別

Microsoft.VisualStudio.TestTools.UnitTesting 命名空間

其他資源

Using the TestContext Class