สร้างโปรเจ็กส์ .NET Core Web Application รองรับ Angular

สร้างโปรเจ็กส์แบบ Web > ASP.NET Core Web Application
Name: TestMakerFreeWebApp
Solution name: TestMakerFree

เลือก
Angular

จะได้โปรเจ็กส์ที่มีโครงสร้างประมาณนี้

โปรเจ็กส์นี้จะมีทั้ง Server และ Client

  • โดย Server จะอยู่ในโฟลเดอร์ Controllers
  • ส่วน Client อยู่ในโฟลเดอร์ ClientApp

สั่ง run จะ Eror ประมาณนี้

[code]
file ‘project.assets.json’ not found. Run a NuGet package restore to generate this file.
[/code]

วิธีแก้
ที่ console พิมพ์คำสั่ง

[code]
dotnet restore
[/code]

สั่ง run อีกที ทีนี้จะรันได้ละ

Test client
หน้า Home

หน้า Counter

หน้า Fetch data

ทีนี้ทดสอบฝั่ง server
Test server

http://localhost:60926/api/SampleData/WeatherForecasts

[{“dateFormatted”:”22/8/2561″,”temperatureC”:20,”summary”:”Mild”,”temperatureF”:67},{“dateFormatted”:”23/8/2561″,”temperatureC”:28,”summary”:”Freezing”,”temperatureF”:82},{“dateFormatted”:”24/8/2561″,”temperatureC”:19,”summary”:”Chilly”,”temperatureF”:66},{“dateFormatted”:”25/8/2561″,”temperatureC”:29,”summary”:”Balmy”,”temperatureF”:84},{“dateFormatted”:”26/8/2561″,”temperatureC”:36,”summary”:”Scorching”,”temperatureF”:96}]

 

Link