# การพัฒนา Web API (.NET) > หลักการ REST, HTTP verb, status code, content negotiation, versioning, การออกแบบ API - 22 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: .NET](https://sharpskill.dev/th/technologies/dotnet/interview-questions.md) ## 1. หลักการ REST ใดที่กำหนดว่า API ต้องไม่เก็บสถานะ session ระหว่างคำขอ? **คำตอบ** หลักการ statelessness กำหนดว่าแต่ละคำขอต้องมีข้อมูลทั้งหมดที่จำเป็นต่อการประมวลผล เซิร์ฟเวอร์จะไม่เก็บบริบท session ระหว่างการเรียกใช้ ซึ่งช่วยเพิ่มความสามารถในการขยายระบบ เพราะคำขอสามารถถูกจัดการโดยเซิร์ฟเวอร์ใดก็ได้โดยไม่ต้องแชร์สถานะ ## 2. ควรใช้ HTTP verb ใดในการสร้าง resource ใหม่ใน REST API? **คำตอบ** POST เป็น HTTP verb มาตรฐานสำหรับการสร้าง resource ใหม่ มันไม่ idempotent: การเรียกแต่ละครั้งจะสร้าง instance ใหม่ โดยทั่วไปเซิร์ฟเวอร์จะกำหนด URI ของ resource ที่สร้างขึ้นและส่งกลับผ่าน header Location พร้อมสถานะ 201 Created ## 3. ควรส่งคืน HTTP status code ใดหลังจากสร้าง resource สำเร็จด้วย POST? **คำตอบ** status code 201 Created บ่งบอกว่า resource ใหม่ถูกสร้างขึ้นสำเร็จ ควรมาพร้อมกับ header Location ที่มี URI ของ resource ที่สร้างขึ้น สิ่งนี้ทำให้ไคลเอนต์สามารถดึง resource ได้ทันทีผ่าน GET ซึ่งต่างจาก 200 OK ที่ไม่ได้ให้ความหมายนี้ ## มีอีก 19 คำถาม - อะไรคือความแตกต่างหลักระหว่าง PUT และ PATCH ใน REST API? - ควรส่งคืน HTTP status code ใดเมื่อ resource ที่ร้องขอไม่มีอยู่? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ .NET อื่นๆ - [พื้นฐาน C#](https://sharpskill.dev/th/technologies/dotnet/interview-questions/csharp-basics.md): 25 คำถาม, Junior - [LINQ & Delegates](https://sharpskill.dev/th/technologies/dotnet/interview-questions/csharp-linq-delegates.md): 20 คำถาม, Junior - [พื้นฐานสำคัญของภาษา C#](https://sharpskill.dev/th/technologies/dotnet/interview-questions/csharp-language-essentials.md): 15 คำถาม, Junior - [พื้นฐาน ASP.NET Core](https://sharpskill.dev/th/technologies/dotnet/interview-questions/aspnet-core-fundamentals.md): 18 คำถาม, Junior - [วงจรชีวิตของ request ใน ASP.NET Core](https://sharpskill.dev/th/technologies/dotnet/interview-questions/aspnet-core-request-lifecycle.md): 20 คำถาม, Junior - [Configuration & Settings](https://sharpskill.dev/th/technologies/dotnet/interview-questions/configuration-settings.md): 20 คำถาม, Junior - [วงจรชีวิตของแอปพลิเคชัน](https://sharpskill.dev/th/technologies/dotnet/interview-questions/application-lifecycle.md): 20 คำถาม, Junior - [Dependency Injection](https://sharpskill.dev/th/technologies/dotnet/interview-questions/dependency-injection.md): 24 คำถาม, Mid-Level - [Entity Framework Core](https://sharpskill.dev/th/technologies/dotnet/interview-questions/entity-framework-core.md): 25 คำถาม, Mid-Level - [Minimal APIs](https://sharpskill.dev/th/technologies/dotnet/interview-questions/minimal-apis.md): 18 คำถาม, Mid-Level - [Async ใน ASP.NET Core](https://sharpskill.dev/th/technologies/dotnet/interview-questions/async-aspnet-core.md): 20 คำถาม, Mid-Level - [Authentication & Authorization](https://sharpskill.dev/th/technologies/dotnet/interview-questions/authentication-authorization.md): 18 คำถาม, Mid-Level - [HttpClient & Networking](https://sharpskill.dev/th/technologies/dotnet/interview-questions/httpclient-networking.md): 20 คำถาม, Mid-Level - [การซีเรียลไลซ์ JSON](https://sharpskill.dev/th/technologies/dotnet/interview-questions/json-serialization.md): 20 คำถาม, Mid-Level - [Entity Framework Core ขั้นสูง](https://sharpskill.dev/th/technologies/dotnet/interview-questions/ef-core-advanced.md): 25 คำถาม, Mid-Level - [ฟีเจอร์ขั้นสูงของ C#](https://sharpskill.dev/th/technologies/dotnet/interview-questions/csharp-advanced-features.md): 20 คำถาม, Mid-Level - [Clean Architecture](https://sharpskill.dev/th/technologies/dotnet/interview-questions/clean-architecture.md): 20 คำถาม, Mid-Level - [Logging, Monitoring & Observability](https://sharpskill.dev/th/technologies/dotnet/interview-questions/logging-monitoring.md): 22 คำถาม, Mid-Level - [Unit Testing และ xUnit](https://sharpskill.dev/th/technologies/dotnet/interview-questions/unit-testing-xunit.md): 20 คำถาม, Mid-Level - [การทดสอบแบบบูรณาการ](https://sharpskill.dev/th/technologies/dotnet/interview-questions/integration-testing.md): 18 คำถาม, Mid-Level - [Docker & Containerization](https://sharpskill.dev/th/technologies/dotnet/interview-questions/docker-containerization.md): 16 คำถาม, Mid-Level - [การจัดการแพ็กเกจ NuGet](https://sharpskill.dev/th/technologies/dotnet/interview-questions/nuget-package-management.md): 16 คำถาม, Mid-Level - [Memory Management & GC](https://sharpskill.dev/th/technologies/dotnet/interview-questions/memory-management-gc.md): 22 คำถาม, Senior - [การเขียนโปรแกรมแบบรีแอกทีฟ](https://sharpskill.dev/th/technologies/dotnet/interview-questions/reactive-programming.md): 24 คำถาม, Senior - [Async/await และรูปแบบ](https://sharpskill.dev/th/technologies/dotnet/interview-questions/async-await-patterns.md): 26 คำถาม, Senior - [.NET Design Patterns](https://sharpskill.dev/th/technologies/dotnet/interview-questions/dotnet-design-patterns.md): 24 คำถาม, Senior - [การเพิ่มประสิทธิภาพการทำงาน](https://sharpskill.dev/th/technologies/dotnet/interview-questions/performance-optimization.md): 22 คำถาม, Senior - [ความปลอดภัยและ Best Practices](https://sharpskill.dev/th/technologies/dotnet/interview-questions/security-best-practices.md): 24 คำถาม, Senior - [SignalR และเรียลไทม์](https://sharpskill.dev/th/technologies/dotnet/interview-questions/signalr-realtime.md): 22 คำถาม, Senior - [สถาปัตยกรรม Microservices](https://sharpskill.dev/th/technologies/dotnet/interview-questions/microservices-architecture.md): 25 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/dotnet/interview-questions/web-api-development