ASP.NET Core API 指定回傳格式為 json

【狀況】
使用 ASP.NET Core 站台建置 API 時,回傳 Guid 字串時,前端(Angular)發生 Exception

【原因】
回傳內容格式,格式被設定為 text
text


【修正】
在 Controller 宣告處加上
 [Produces("application/json")]
回傳格式就會自動設定為 json
text


以上,收工!

留言