概要: ASP.NET is a flexible set of tools and web development technologies that allows you to employ a number of applications based on the ASP.NET framework.

In this topic, you will learn how to configure the server-wide ASP.NET settings in Plesk.

概要

Plesk supports ASP.NET 2.0 and 4.x, as well as ASP.NET Core 2.1 and later. Most ASP.NET configuration settings that commonly need to be customized in order for ASP.NET applications to function in a desirable way can be edited through Plesk.

要配置伺服器級的 ASP.NET 設定,請執行下列步驟:

  1. 登錄到 Plesk

  2. Go to Tools & Settings > ASP.NET Settings (under 「Applications & Databases」). The settings for different versions of ASP.NET are located under the corresponding tabs.

    image asp net settings

  3. Set up the strings that determine database connection data for ASP.NET applications which use databases:

    當您首次打開ASP.NET 配置頁面時,將看到顯示出常用構造的示例連接參數。您可刪除這些參數並指定自己的字串。

    • To add a string, click Add one more.
    • 要刪除字串,請按一下該字串旁的 image cross icon
  4. 創建被 ASP.NET 應用程式返回的自訂錯誤資訊:

    • 若要設定自訂錯誤消息模式,請從 「自訂錯誤模式」 功能表中選擇相應的選項:

      • 開啟 - 自訂錯誤資訊已啟用。
      • 關閉 - 自訂錯誤資訊已禁用,同時顯示出詳細的錯誤資訊。
      • 僅限遠端 - 僅對遠端使用者顯示自訂錯誤資訊,本地主機只顯示 ASP. NET 錯誤資訊。
    • To add a custom error message (which will be applied unless the Off mode was selected), enter the values in the 「Custom errors」 fields.

      • 狀態碼 參數對導致重定向到錯誤頁面的 HTTP 狀態碼進行定義。
      • 重定向 URL 參數對錯誤頁面的 web 位址進行定義,該錯誤頁面將錯誤資訊呈現給用戶端。

      由於可能出現的衝突,您無法添加自訂錯誤消息(錯誤代碼已存在),但是您可以為現有代碼重新定義 URL。

    • 要從清單中刪除自訂錯誤消息,請按一下該消息旁的 image cross icon

  5. Configure compilation settings:

    • 設定用於動態編譯檔的預設程式設計語言,可從 「預設網頁語言」 清單中選擇項。

    • 要啟用編譯二進位發行代碼,請將 「啟用調試」 核取方塊保留為空。

    • 要啟用編譯二進位調試代碼,請選中 「啟用調試」 核取方塊。這種情況下,包含錯誤的原始程式碼片斷將顯示在診斷頁面消息中。

      備註: 在調試模式下運行應用程式會消耗記憶體和/或降低性能。建議在測試應用程式時使用調試模式;在部署應用程式到產品方案之前則禁用此模式。

  6. Configure encoding settings for ASP.NET applications:

    • 要設定所有傳入請求採用的編碼,請在 「請求編碼」 欄位中輸入一個編碼值(預設為 Utf-8)。
    • 要設定所有回應採用的編碼,請在 「響應編碼」 欄位中輸入一個編碼值(預設為 Utf-8)。
    • 要設定用於解析 .aspx.asmx.asax 檔的預設編碼,請在 「檔編碼」 欄位中輸入一個編碼值(預設為 Windows-1252)。
    • 要設定處理傳入 web 請求時所需的默認區域性,請在 「區域性」 列表中選擇相應項。
    • To set a culture which must be used by default when processing searches for a locale-dependent resource, select an appropriate item from the 「UI Culture」 list.
  7. Set a code access security trust level for ASP.NET applications:

    CAS 信任級別是一組應用到應用程式的功能限制。例如,低級別會限制應用程式的網路功能(如發送郵件)而完全信任級別則會移除任何限制。

    • 若要更改網站的 CAS 信任級別,請選擇核取方塊 「允許為單個網站更改 CAS 信任級別」 。如果您沒有選擇該核取方塊,網站將會使用伺服器範圍的設定。或者,每個網站都可以在網站主機設定中指定自己的 CAS 信任級別。

      備註: 如果一個程式集被分配的信任級別過低,則該程式集將不能正常運行。欲瞭解更多有關許可權層級的資訊請參閱 https://msdn.microsoft.com/en-us/library/Aa302425

  8. 在 「會話設定」 欄位中設定客戶會話參數:

    • 要設定應用程式的預設驗證模式,請從 「驗證模式」 清單中選擇合適的選項。請注意,只要使用了 IIS 驗證,就必須選擇 「Windows」 驗證模式。
    • 要設定會話在被放棄前的閒置時間,請在 「會話超時」 欄位中輸入相應的分鐘數。
  9. 按一下 保存 以應用所有更改。

備註: Plesk 支援獨立配置 .NET framework 的不同版本。

備註: If you want to use ASP.NET Core web applications, select the 「Microsoft ASP.NET Core 」 component when installing Plesk. After that, you can upload your ASP.NET Core application to your web site and use it. In this case, it is recommended to switch off the ASP.NET support for your domain to save server resources. To do so, go to Websites & Domains > find the domain that will host your application > go to the 「Hosting & DNS」 tab > Hosting and clear the Microsoft ASP.NET checkbox.