Blog

qtq80-dp1eqm
16 Ti 2017

ASP.NET ntawm OpenShift: Mus pib hauv ASP.NET

/
Muab tso rau By

Vim li cas tus Introduction to ASP.NET ntawm OpenShift?

Ua ASP.NET kev loj hlob siv OpenShift, Kuv twb pom tias ob peb cov kev qhia tawm muaj pib rau ASP.NET yog

a) qhov siab tshaj plaws ntawm lub hlwb, thiab

b) Tsis txhob mus hla cov kev cai li nws ua haujlwm

Nyob rau hauv rooj plaub yuav siv ASP.NET ntawm OpenShift, koj yuav tsum muaj lub peev xwm los to taub nws!

Nyob rau hauv qhov kev qhia ntawm kev qhia ntaub ntawv, Kuv yuav dhia ntawm lub sijhawm uas yuav qhia tau koj cov kev nkag siab ntawm ASP.NET kev ua haujlwm thiab koj ua dab tsi ua ntej koj pib muab koj cov kev cuam tshuam rau OpenShift. Peb mam li mus rau qhov ntawd hauv ib tsab xov xwm sai txaus.

Hauv seem 1 thiab 2 ntawm qhov kev qhia ntawm qhov kev qhia, Kuv yuav dhau mus pib sai dua los ntawm kev siv cov duab nyob hauv Visual Studio Community 2015. Qhov no txhais tias nws yuav ua rau lub qhov rais hauv seem no. Nyob rau hauv txhua rooj plaub, Kuv yuav khiav ntau tshaj rau hauv qab nrog ua txhua yam tsis muaj layouts nyob rau hauv Visual Studio Code ntawm kev noj tom qab kev qhia ntawv, uas yuav muaj feem xyuam rau Linux lossis Mac thiab ntxiv rau Windows. Nyob rau hauv cov ntaub ntawv koj tsis siv lub Windows, koj tau nyob rau hauv txhua rooj plaub siv tom qab nyob rau hauv qhov chaw 1 thiab 2 kom tau ib qho kev xav txog yuav ua li cas ua ib end endpoint nyob rau hauv .NET Core.

Peb Yuav Tsum Pib!

Seem 1 - Teem Txog ASP Service

Yuav pib rau koj los ntawm kev tsim cov kev pabcuam ASP uas yog siv Kev Xaiv Tsev. Kuv xav tau los xyuas kom meej tias ua li cas Controllers muaj nuj nqis ua ntej yuav tsiv mus rau MVC.

UA KOJ LUB PROJECT

Hauv kev Txhim Kho Studio (Kuv tabtom siv Community Edition 2015) nias Cov Ntawv Thov thiab tom qab Xa Ntawv Tshiab.

Nyob rau hauv Templates -> Visual C # -> Web Organizer, xaiv ASP.NET Core Web Application (.NET Core). Nws yog ib qho tseemceeb uas koj xaiv tau tus .NET Core thiab tsis tus .NET Framework raws li qhov no yog qhov chaw ua ntaub ntawv thov .NET.

project-1024x552 ASP.NET ntawm OpenShift: Pib tau hauv ASP.NET

Sau koj lub npe venture - qhov no tuaj yeem ua txhua yam koj nyiam, hauv qhov kev qhia no kuv yuav hu nws ua MeowWorld.

Raws li ib qho teeb meem, qhov chaw no yuav yog nyob hauv koj qhov Visual Studio Projects, tab sis tseem tsis tau hloov siab hloov qhov no rau qhov kev tshwm sim uas koj xav tau ib qho ncaws tawm ntawm lub sij hawm los khaws cov kev cob qhia ntawm lwm qhov.

Peb yuav tsum ua kom lwm txoj kev tshiab (ua teb zoo li lub tswv yim lag luam uas muaj ntau yam kev ua haujlwm uas koj yuav ua nrog) thiab peb yuav tsum tau sau npe rau lub sijhawm.

Raws li ib qho teeb meem, cov txheej txheem muaj npe tib yam li koj qhov chaw venture. Qhov no yog splendidly zoo, yog li tso tseg nws raws li tej zaum yuav. Ua li ntawd nws yuav, koj nyob nraum ntau tshaj txais tos los rename nws nyob rau hauv qhov kev tshwm sim uas koj xav tau ib kick tawm ntawm lub caij nyoog.

Nco ntsoov tsim kom muaj cov Directory - qhov no tsis yog qhov tseemceeb rau lub sijhawm uas koj nkag siab koj tau ua dabtsi, tabsis nws pabcuam ntau yam nrog rau kev ua haujlwm.

Koj tuaj yeem tau muaj Visual Studio ua ib lub khw mus lawm. Kuv yuav tsis ua li ntawd vim tias qhov no yog ib qho kev cob qhia, tsis tau rau siab loj, koj yuav tsum tau.

Thaum twg koj muaj cov ntsiab lus nrog txhua qhov ntawm qhov chaw, nyem qhov yoojyim kom tsiv mus rau cov nram qab no.

Xaiv koj TEMPLATE

Ntawm no koj yuav tsum muaj peb txoj kev xaiv. Rau qhov kev qhia ntawm no, koj yuav tsum xaiv qhov Web API xaiv. Kuv mam li nkag mus rau lwm qhov ob nrog cov tutorials yav tom ntej.

template-1-300x234 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Nyob rau lub caij nyoog uas koj sib sau ua ke thiab khiav qhov kev sib tw ntawm lub sij hawm no, nws yuav qhib qhov rai qhov kev pab cuam (los yog tab) thiab coj koj mus rau ... / programming interface / qhov tseem ceeb / - uas yuav qhia tau JSON pawg qhia txog qhov no:

api-qhov tseem ceeb-300x66 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Kaw koj qhov kev zov me nyuam thiab xyuas kom koj nres koj txoj kev ua lag luam los ntawm cov zauv dub liab (uas hais tias "Txiav Debugging" thaum koj nas-tshaj) nrog lub hom phiaj uas koj tuaj yeem hloov tau.

KOJ LI CAS LI

Hauv qhov chaw Xam Phem, mus rau Kev Xa Tshuaj -> src -> Project Name -> Controllers -> ValuesController.cs thiab qhib nws.

Pom li cas txhua qhov ntawm txoj kev muaj HTTP ... "kev zoo siab nrog lawv (HttpGet, HttpPost, HttpPut, thiabHttpDelete). Qhov no yog qhov http txoj kev - HttpGet` yog qhov kev khiav ntawm zeb ib qho siv kom nkag mus rau phab web. Cov lus yuav raug xa mus rau txhua txoj kev raws li cov lus nug txoj hlua (los yog cov ntaub ntawv qhia - ntxiv rau cov kev tom qab).

Txoj Cai-Nias ntawm lub hnab ntawv tswj thiab ua lwm chav kawm hu ua CatController.

maub los-300x162 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Ntxiv qiv ntawv Microsoft.AspNetCore.Mvc pab khaws koj cov cai kom zoo.

Ntxiv cov lus qhia Meow rau koj hoob kawm:

chaws-2-254x300 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Tam sim no khiav code. Nyob rau hauv koj qhov kev pab, affix / miv / nqi / mus rau localhost: ##### pom koj ua haujlwm hauv lub neej tiag tiag.

feline-nqi-300x66 ASP.NET rau OpenShift: Txiav pib hauv ASP.NET

Koj tau hloov HttpGet ("/ cat / bill") rau perse HttpGet ("miv / nqi") thiab hloov lub npe ntawm txoj kev los ntawm txoj hlua yas "Yowl ()" qhib hlua Bill ().

Nco ntsoov tias tsis pub lub npe ntawm tus neeg saib xyuas lossis txoj kev cuam tshuam txoj kev. Nws yog kev xyaum ua kom txhua yam sib npaug li cas los xij, thiaj li rov ua dua tshiab cov cai:

chaws-3-254x300 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Tam sim no li cas peb muaj xws li lwm cov miv!

chaws-4-188x300 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Tam sim no koj tuaj yeem khiav txoj cai thiab qhib koj lub program rau: ... / cat / steve /

cat-steve-300x66 ASP.NET ntawm OpenShift: Pib tau rau hauv ASP.NET

Peb tuaj yeem ua haujlwm nrog rau cov miv, tabtom ua ib txoj kev rau txhua tus tuaj yeem ua kom khaus, yog li peb hloov qhov ntawd. Peb tuaj yeem siv sib cav sib ceg rau lub npe miv uas yuav dhau los ua ib txoj hlua lus nug. Yog li peb cov cai tau tam sim no zoo li no:

chaws-5-194x300 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Tam sim no khiav code thiab tso nyiaj rau koj tus browser: ... / miv? miv = daim nqi thiab ces ... / miv? miv = steve

Tam sim no peb muaj cov miv hauv ib txoj kev zoo sib xws, tiam sis qhov URL yog me ntsis jumbled. Qhov no yog qhov chaw uas yuav muaj los ntawm txoj kev khiav haujlwm. Txhua yam peb xav tau yog hloov me ntsis rau txoj cai:

chaws-6-194x300 ASP.NET rau OpenShift: Mus pib hauv ASP.NET

Txuas ntxiv, tam sim no peb muaj peev xwm backpas siv los siv: ... / miv / nqi thiab ... / miv / steve.

Nov yog thawj zaug ntawm qhov kev nthuav qhia no. Hauv kev ua ob txoj hau kev rau miv thiab lawv hais li cas, koj twb pib ua cov ASP.NET web service nrog ob tug API hu! Kuv tus ncej tom ntej yuav sib tham txog kev txais thiab teeb cov ntaub ntawv, thiab kev sib tw ua haujlwm li cas, thaum peb tuaj yeem ua rau cov menyuam loj hlob tuaj.

Sau ntawv cia Ncua

 
GTranslate Please upgrade your plan for SSL support!
GTranslate Your license is inactive or expired, please subscribe again!