WebApiConfig.Register 中必須呼叫 config.EnableCors();。[EnableCors(...)] 可加在 Controller 或 Action 上,若加在 Action 需確保 Controller 未被 [DisableCors] 標記。origins: "https://localhost:40226" 必須與瀏覽器發送的 Origin 標頭**完全一致**(含協定、埠號、無尾斜線)。OPTIONS,需確保 IIS/ASP.NET 管線允許 OPTIONS 通過(<modules runAllManagedModulesForAllRequests="true">)。headers: "*", methods: "*" 通常足夠,若仍失敗請明確列出 Content-Type, Authorization 等。瀏覽器 Network 面板查看 OPTIONS 回應是否包含 Access-Control-Allow-Origin、Access-Control-Allow-Methods、Access-Control-Allow-Headers。若缺少,檢查管線順序與 web.config <cors> 設定。