2025年11月13日 星期四

[研究]「ASP.NET 部分信任 (Partial Trust)」的支援狀況

[研究]「ASP.NET <trust level> 部分信任 (Partial Trust)」的支援狀況

2025-11-13

新版本 .NET 中不再支援 包含 .NET Framework 2.0 ? .NET Framework 3.51 SP1 ? .NET Framework 4.0 ? .NET Framework 4.5 ? .NET Framework 4.8 ? 其他 ?

ChatGPT

這是一個非常關鍵的問題,因為「ASP.NET <trust level> 部分信任 (Partial Trust)」的支援狀況,確實隨著 .NET Framework 版本演進逐步退場。

以下是完整的版本對照與微軟官方說明依據整理:

🧩 一、總覽表:各版本對 Partial Trust(部分信任)的支援狀態

.NET 版本 發布年份 Partial Trust(信任層級設定)支援狀況 備註
.NET Framework 1.0 / 1.1 2002–2003 ✅ 完全支援 最初設計就包含 Code Access Security (CAS)
.NET Framework 2.0 2005 ✅ 完全支援 <trust level="High/Medium/Low/Minimal"> 可正常運作
.NET Framework 3.0 / 3.5 / 3.5 SP1 2006–2008 ✅ 支援 ASP.NET 與 WCF 都支援 Partial Trust
.NET Framework 4.0 2010 ⚠️ 預設改為「Full Trust」,但仍支援 CAS 與 Partial Trust;Microsoft 已開始不建議使用 微軟開始標註「不推薦」
.NET Framework 4.5 / 4.5.1 / 4.5.2 2012–2014 ⚠️ 仍支援,但微軟宣布「CAS 不再建議使用」 僅保留向下相容性
.NET Framework 4.6 / 4.6.1 / 4.6.2 / 4.7 / 4.8 / 4.8.1 2015–2022 ⚠️「仍能啟用」但已標記為 Deprecated (已淘汰);官方明確指出 CAS/Partial Trust 已不再有效 ASP.NET 雖仍解析 <trust>,但實際上大部分不會限制權限

敝人註:只要遇到少部分仍會限制,但網站系統必須用到的功能,網站功能就癱瘓了
.NET Core 1.x / 2.x / 3.x 2016–2019 完全不支援 無 CAS、無 Partial Trust
.NET 5 / 6 / 7 / 8 / 9 (含 ASP.NET Core) 2020–2025 完全移除 微軟文件中註明「Partially trusted code is no longer supported」

🧠 二、微軟官方參考來源(含直接引文)

ASP.NET 部分信任不保證可成功進行應用程式隔離
https://support.microsoft.com/zh-tw/topic/asp-net-%E9%83%A8%E5%88%86%E4%BF%A1%E4%BB%BB%E4%B8%8D%E4%BF%9D%E8%AD%89%E5%8F%AF%E6%88%90%E5%8A%9F%E9%80%B2%E8%A1%8C%E6%87%89%E7%94%A8%E7%A8%8B%E5%BC%8F%E9%9A%94%E9%9B%A2-70557652-8a02-6f90-fb64-dfc16eafa7a7

ASP.NET Partial Trust does not guarantee application isolation
https://support.microsoft.com/en-us/topic/asp-net-partial-trust-does-not-guarantee-application-isolation-70557652-8a02-6f90-fb64-dfc16eafa7a7

ASP.NET Trust Levels and Policy Files
https://learn.microsoft.com/en-us/previous-versions/aspnet/wyts434y(v=vs.100)

Code Access Security (CAS) is no longer recommended as a security mechanism.
https://learn.microsoft.com/en-us/previous-versions/dotnet/framework/code-access-security/code-access-security

Partial trust
https://learn.microsoft.com/en-us/dotnet/framework/wcf/feature-details/partial-trust

That assembly does not allow partially trusted callers
https://learn.microsoft.com/en-us/answers/questions/858271/that-assembly-does-not-allow-partially-trusted-cal


📘 三、重點結論摘要

時期 支援狀態 微軟態度
.NET 1.0–3.5 SP1 ✅ 完全支援 推薦用於共享主機隔離
.NET 4.0–4.5.2 ⚠️ 可用但不建議 微軟開始宣導使用 Full Trust 模式
.NET 4.6–4.8.1 ⚠️ 形式支援,但實際效果被弱化或忽略 微軟正式標記為「已過時」(Obsolete)
.NET Core / .NET 5+ ❌ 完全不支援 CAS/Partial Trust 完全移除

(完)

相關

[研究]「ASP.NET 部分信任 (Partial Trust)」的 3rd Party 套件/元件支援狀況https://shaurong.blogspot.com/2025/11/aspnet-partial-trust-3rd-party.html

[研究]GCB,IIS,\system.web\trust\level 變更影響?
https://shaurong.blogspot.com/2025/11/gcbiissystemwebtrustlevel.html

[研究]「ASP.NET 部分信任 (Partial Trust)」的支援狀況
https://shaurong.blogspot.com/2025/11/aspnet-partial-trust.html


沒有留言:

張貼留言