Blog

qtq80-dp1eqm
16 Mar 2017

ASP.NET pa OpenShift: Kuyamba mu ASP.NET

/
Posted by

N'chifukwa Chiyani Mau Oyamba a ASP.NET pa OpenShift?

Pochita chitukuko cha ASP.NET pogwiritsa ntchito OpenShift, ndapeza kuti masewera angapo kunja kwa ASP.NET ali

a) kuganiza mozama kwambiri, ndi

b) musapitenso pazimene zimagwira ntchito

Ngati mungagwiritse ntchito ASP.NET pa OpenShift, muyenera kukhala ndi mphamvu yomvetsetsa!

Phunziroli, ndikudumpha mpata kukupatsani chidziwitso chofunikira cha momwe ASP.NET ikugwirira ntchito ndi zomwe mukuchita musanayambe kuyika zochitika zanu pa OpenShift. Tidzafika ku izo mu nkhani posachedwa.

M'madera ena 1 ndi 2 za masewera olimbitsa thupi awa, ndikupita ndikuyamba mwamsanga pogwiritsa ntchito zigawo mu Visual Studio Community 2015. Izi zikutanthawuza kuti zidzakhala za Windows m'gawo lino. Mulimonsemo, ine ndikuthamanga pamwamba mpaka pansi ndikuchita zonse popanda zigawo mu Visual Studio Code mukutenga zochitika zolimbitsa thupi, zomwe zingakhale zogwirizana ndi Linux kapena Mac komanso kuwonjezera Mawindo. Ngati simukugwiritsa ntchito Windows, mungathe kumatsatira mbali zina 1 ndi 2 kuti mupeze lingaliro lalikulu la momwe mungapangire mapeto a REEST mu NET Core.

Tiyenera kuyamba!

Gawo 1 - Kukhazikitsa Ntchito ya ASP

Adzayamba ndi kupanga ntchito yofunikira ya ASP pogwiritsa ntchito Woyang'anira. Ndikufuna kuonetsetsa kuti mukuwona momwe ma Controllers amagwirira ntchito musanayambe kupita ku MVC.

MUZIPEREKA

Mu Visual Studio (Ndikugwiritsa ntchito Community Edition 2015) dinani Fayilo ndipo kenako Pulojekiti Yatsopano.

Pansi pa Zithunzi -> Zithunzi C # -> Wokonza webusaiti, sankhani ASP.NET Core Web Application (NET Core). Ndikofunika kwambiri kuti musankhe NET Core osati ku .NET Framework monga iyi ndilai ya .NET yomwe ili pamasitepe.

project-1024x552 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Lowani dzina lanu lachitukuko - ichi chikhoza kukhala chirichonse chomwe mungakonde, muchithunzitsi chophunzitsira ichi ndikuchitcha MeowWorld.

Monga mwachidziwikire, malo awa adzakhala mu bungwe lanu la Visual Studio Projects, komabe musazengereze kusintha izi mukakumbukira kuti mutha kuchoka pa mwayi kuti muzisunga masewera olimbitsa kwinakwake.

Tiyenera kupanga njira zina (yankho likufanana ndi a ace venture omwe amagwira ntchito zosiyanasiyana zomwe mukugwira nawo ntchito) ndipo tifunika kutchula dongosololi.

Monga mwachidziwikire, dongosololi limatchulidwa mofanana ndi malonda anu. Izi ndi zabwino kwambiri, choncho zisiyani. Khalani monga momwe zingakhalire, ndinu olandiridwa kwambiri kuti muzitchulidwenso pokhapokha mutakhala ndi mwayi wokhala nawo mwayi.

Onetsetsani Kuti Pangani Zolemba Zowonongeka - izi sizowona mwakusowa kuti mumvetse zomwe mukuchita, koma zimathandiza kwambiri ndikusunga zinthu.

Momwemonso mungathe kukhala ndi Visual Studio kupanga gwiritsani mwachibadwa. Sindidzachita izi ngati izi ndizochita masewera olimbitsa thupi, komabe pakukula kwakukulu, mungafunikire.

Mukakhala okhutira ndi zochitika zonse, dinani Kulungani kuti mupite kumalo otsatirawa.

SANKANI KUYAMBA KWANU

Pano iwe uyenera kukhala ndi zisankho zitatu. Pulogalamuyi, muyenera kusankha Web API kusankha. Ndilowa mu zina ziwiri ndi maphunziro amtsogolo.

template-1-300x234 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Mwayi wokha kuti muzisonkhanitsa ndi kuyendetsa ntchito panthawiyi, idzatsegula zenera (kapena tab) ndikukutengerani ku ... / mawonekedwe a mapulogalamu / zoyenera / - zomwe zidzasonyeze gulu la JSON likuwonetsa izi:

Zotsatira za api-300x66 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Tsekani pulogalamu yanu ndikuonetsetsa kuti mukuyimitsa ntchito yanu pofikira kofiira yamtundu wofiira (yomwe imati "Pewani kuchotsa" pamene mukugwiritsira ntchito mouse) ndi cholinga chomwe mungasinthe.

KUTHANDIZA KUSANGALALA KWANU

Mu Solution Explorer, pitani ku Solution Name -> src -> Name Project -> Olamulira -> ValuesController.cs ndi kutsegula.

Onani momwe njira zonse zili ndi Http ... "zofanana ndizo (HttpGet, HttpPost, HttpPut, ndiHttpDelete). Iyi ndi njira ya http - HttpGet` ndikuthamanga kwa mphero imodzi yomwe ikugwiritsidwa ntchito popita ku tsamba la intaneti. Mikangano ikhoza kupitsidwira ku njira iliyonse monga zinthu zothandizira (kapena data data - zambiri pa njira kenako).

Lembani pawombululi oyendetsa bokosi ndikupanga gulu lina lotchedwa CatController.

Mtsogoleri-300x162 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Onjezerani makalata a Microsoft.AspNetCore.Mvc kuti musunge code yanu bwino.

Onjezerani njira yotsatirayi ya Meow ku kalasi yanu:

Code-2-254x300 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Tsopano muthamangire code. Mu pulogalamu yanu, chiyanjano / kato / ndalama / localhost: ##### kuti muwone ntchito yanu mmoyo weniweni.

Phinepala-300x66 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Mukusintha HttpGet ("/ paka / Bill") kuti muwononge HttpGet ("chipha / bilo") ndikusintha dzina la njirayo kuchokera pa chingwe cha pubic "Yowl ()" kutsegula Bill ().

Dziwani kuti dzina la wolamulirayo kapena njirayo silimakhudza njirayo. Ndizozoloŵera nthawi zonse kuti zonse zifanane, komabe, zotsitsimutsani kachidindo:

Code-3-254x300 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Tsopano nanga bwanji ife tikuphatikizapo kamba ina!

Code-4-188x300 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Tsopano mutha kuthamanga kachidindo ndikutsegula pulogalamu yanu kuti: ... / paka / steve /

katsamba-300x66 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Titha kupitirizabe kukhala ndi amphaka, komabe kupanga njira kwa aliyense kungakhale kokwiyitsa bwino, kotero bwanji tikasintha izo. Tingagwiritse ntchito mikangano ya dzina la paka lomwe lidzaperekedwa monga chingwe cha funso. Kotero code yathu ikhoza kufanana ndi iyi:

Code-5-194x300 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Tsopano muthamangire kachidindo ndikuwongolera osatsegula anu kuti: ... / cat? cat = ndalama Kenako ... / cat? cat = steve

Tsopano tili ndi amphaka mwanjira yomweyi, komabe URL imangokhalira kugwedezeka. Izi ndi malo omwe amapita kudzera njira zomwe zimayambira. Zonse zomwe tikufunikira ndi kusintha pang'ono kwa code:

Code-6-194x300 ASP.NET pa OpenShift: Kuyamba mu ASP.NET

Komanso, tsopano tingathe kugwiritsa ntchito izi: ... / kato / ndalama ndi ... / kato / steve.

Izi ndizo gawo loyamba lawonetserako. Pogwiritsa ntchito njira ziwiri za amphaka ndi zomwe akunena, wayamba kupanga webusaiti ya ASP.NET ndi mafoni awiri API! Chotsatira changa chidzafotokozera kupeza ndi kuyika deta, ndi momwe magawo akugwirira ntchito, pamene tikukula chiwombankhanga.

GTranslate Your license is inactive or expired, please subscribe again!