Cov txheej txheem:

Kuv yuav ntxiv API rau Visual Studio li cas?
Kuv yuav ntxiv API rau Visual Studio li cas?

Video: Kuv yuav ntxiv API rau Visual Studio li cas?

Video: Kuv yuav ntxiv API rau Visual Studio li cas?
Video: txhob yuam koj los hlub kuv ntxiv by maiv xis hawj 2022 2024, Kaum ib hlis
Anonim

Pib Daim Ntawv Thov

  1. Tsim ib qho ASP. NET Web API qhov project. Sab hauv Visual Studio , xaiv 'File' -> 'New Project' zaub mov.
  2. Configure lub Web API project siv lub zos IIS. Hauv 'Kev daws teeb meem Explorer' qhov rai, nyem rau ntawm 'webDemo' qhov project thiab nyem rau 'Properties' cov ntawv qhia zaub mov.

Kuj nug, API hauv Visual Studio yog dab tsi?

APIs , luv luv rau "application programming interface", tso cai rau koj nkag mus rau ntau yam kev ua haujlwm thiab cov txheej txheem nthuav tawm los ntawm kev ua haujlwm lossis lwm yam kev siv (DLLs), kev ua haujlwm tsis nquag siv los ntawm tus qauv virtual tshuab uas Visual Basic muab.

Ib yam li ntawd, kuv yuav ntxiv swagger rau Web API li cas? Rau ntxiv Swagger rau Web API , peb tsuas yog yuav tsum tau nruab qhov qhib qhov project hu ua Swashbuckle ntawm NuGet. Kauj ruam 2 Nruab Swagger los ntawm NuGet. Tom qab kev teeb tsa, koj tuaj yeem pom swaggerconfig. cs hauv app_start folder hauv koj qhov project.

Ib yam li ntawd, kuv yuav ua li cas khiav Web API code hauv Visual Studio?

Qhib Visual Studio Code , nyem rau ntawm Cov Ntaub Ntawv → Qhib Folder… thiab xaiv peb cov tshiab web API nplaub tshev. Tos ob peb feeb thiab koj yuav pom txhua qhov project cov ntsiab lus. Qhib Startup. cs peb tuaj yeem pom tias dotnet tau tsim lub ntsiab configuration code npaj siv.

REST API piv txwv yog dab tsi?

A REST API txhais cov haujlwm uas cov neeg tsim khoom tuaj yeem ua tau thov thiab tau txais cov lus teb ntawm HTTP raws tu qauv xws li GET thiab POST. Lub Ntiaj Teb Wide Web (WWW) yog ib qho piv txwv ntawm ib tug faib system uas siv REST raws tu qauv architecture muab ib tug hypermedia tsav interface rau cov websites.

Pom zoo: