blog

qtq80-dp1eqm
16 Mar 2017

ASP.NET a kan OpenShift: Farawa a ASP.NET

Me yasa Gabatarwa zuwa ASP.NET akan OpenShift?

A yayin da ake yin ASP.NET ci gaba da amfani da OpenShift, Na gano cewa wasu kwararru daga wurin don fara a kan ASP.NET sune

a) wuce gona da iri da hankali, kuma

b) Kada ku yi la'akari da yadda ake aiki

Idan har za ta yi amfani da ASP.NET a kan OpenShift, ya kamata ka sami damar fahimtar shi!

A cikin wannan shiri na koyarwa, zan yi tsalle a cikin damar da zai ba ku fahimtar muhimmancin yadda ASP.NET ke aiki da abin da kuke yi kafin ku fara aikinku akan OpenShift. Za mu samu wannan a cikin labarin ba da da ewa ba.

A cikin sassan 1 da 2 na wannan motsi, zan fara tafiya da sauri ta yin amfani da shimfidawa a cikin Kayayyakin Gidan Lantarki na Visual Studio 2015. Wannan yana nuna cewa zai kasance ga Windows a wannan bangare. A kowane hali, zan ci gaba da sama da ƙasa tare da yin duk abin da ba tare da shimfidawa ba a cikin Kayayyakin aikin hurumin kalma a cikin ɗaukar bayan motsawar horo, wanda zai dace da Linux ko Mac kuma a Bugu da ƙari Windows. Idan ba a yi amfani da Windows ba, za a iya yin amfani da su a cikin sassa na 1 da 2 don samun ra'ayi na gaba game da yadda za a sami sakamako na REST a cikin .NET Core.

Ya kamata mu fara!

Sashe na 1 - Ƙaddamar da Asp Service

Za a fara ku ta hanyar yin sabis na ASP mai amfani da mai sarrafawa. Ina buƙatar tabbatar da ganin yadda masu kula suke aiki kafin motsi gaba zuwa MVC.

KA YI GANUKA

A cikin Kayayyakin aikin kwaikwayo na (Ina amfani da Ƙungiyar Ɗauki na Ƙasa 2015) danna File kuma daga bisani Sabon Shirin.

A karkashin Samfura -> Kayayyakin C # -> Mai shirya yanar gizo, zaɓi ASP.NET Kayan Yanar gizo (.NET Core). Yana da mahimmanci cewa ka zaɓi NET Core kuma ba NET Framework kamar yadda wannan shi ne ɗakin karatu na gine-gine .NET.

Nano-1024x552 ASP.NET-aiki a kan OpenShift: Farawa a ASP.NET

Shigar da sunan kamfani - wannan zai iya zama duk abin da kake so, a cikin wannan darasi na motsawa zan kira shi MeowWorld.

A gaskiya, wannan wuri zai kasance a cikin Mai tsara Shirye-shiryen Ayyukan Gidan Hanya, duk da haka kada ku yi shakka don canza wannan a yayin da za ku yi kisa daga damar da za ku adana aikin gwaji a wani wuri.

Muna buƙatar yin wani tsari (amsar tana kama da wata hanya ce da ke riƙe da ayyukan da za ku yi aiki tare da) kuma muna buƙatar sunan wannan tsari.

A gaskiya, an tsara wannan tsari kamar yadda kuka samu. Wannan yana da kyau sosai, don haka watsi da shi kamar yadda yake. Kasance cewa kamar yadda yake, kun kasance fiye da maraba don sake sa shi a yayin da za ku sami damar bugawa daga cikin damar.

Tabbatar Ƙirƙiri Directory an kayyade - wannan ba mahimmanci ba ne a kan ƙananan damar da za ka fahimci abin da kake yi, amma hakan yana taimakawa sosai wajen kiyaye abubuwa.

Hakanan zaka iya samun Kayayyakin Kayayyakin Kasuwanci a fili. Ba zanyi haka ba saboda wannan aikin motsa jiki ne, duk da haka don ƙarami mai girma, zaka iya buƙata.

Lokacin da kun yarda da kowane ɗayan saitunan, danna Ya yi don matsawa zuwa gaba ɗaya.

SANTA KUMA KUMA

Anan ya kamata ka sami zabi uku. Domin wannan motsi na horo, kana buƙatar zabi zabi na API. Zan shiga cikin biyu tare da koyaswar gaba.

samfuri-1-300x234 ASP.NET a kan OpenShift: Farawa a ASP.NET

A yayin da kake tarawa da kuma gudanar da kasuwancin a wannan lokaci, zai bude taga (ko shafin) shirin ... / shirin neman bayanai / dabi'u - wanda zai nuna jigon JSON yana nuna wannan:

Ayyuka-300x66 ASP.NET akan OpenShift: Farawa a ASP.NET

Rufe shirinku kuma tabbatar da cewa ku dakatar da aikinku ta hanyar yin amfani da ƙuƙwalwar ja (abin da ya ce "Quit Debugging" lokacin da kake haɗari) tare da burin da zaka iya canza shi.

SANTA GANARKA

A Magani Magani, je zuwa Magani Sunan -> src -> Rubin Shirin -> Masu Gudanarwa -> ValuesController.cs kuma buɗe shi.

Dubi yadda kowanne daga cikin hanyoyi na da Http ... "alama da aka danganta da su (HttpGet, HttpPost, HttpPut, daHttpDelete). Wannan ita ce hanyar http - HttpGet` shi ne gudu daga injin wanda aka yi amfani dashi don samun shafin yanar gizon. Za a iya jituwa ta kowane hanya kamar yadda bincike ke faruwa (ko bayanin bayanai - ƙarin a kan hanyoyi daga baya).

Dama-Danna kan ambulafinsu masu sarrafawa kuma su sanya wani aji mai suna CatController.

mai kulawa-300x162 ASP.NET a kan OpenShift: Farawa a ASP.NET

Ƙara ɗakin karatu na Microsoft.AspNetCore.Mvc don taimakawa wajen kiyaye lambarka cikakke.

Ƙara hanya ta Meow da za a bi zuwa kundinku:

code-2-254x300 ASP.NET a kan OpenShift: Farawa a ASP.NET

Yanzu gudu lambar. A cikin shirinku, affix / cat / lissafin / to localhost: ##### ganin aikinku a hakikanin rayuwa.

feline-bill-300x66 ASP.NET a kan OpenShift: Farawa a ASP.NET

Kuna yin amfani da HttpGet ("/ cat / bill") don karanta HttpGet ("cat / lissafin") da kuma canza sunan hanyar daga launi mai suna "Yowl ()" don buɗe launi Bill ().

Yi la'akari da haka ba sunan mai kulawa ko hanyar da take tasiri ba. Aiki na yau da kullum don yin duk abin da ya dace, don haka sabunta lambar:

code-3-254x300 ASP.NET a kan OpenShift: Farawa a ASP.NET

To yaya zamu hada da wani cat!

code-4-188x300 ASP.NET a kan OpenShift: Farawa a ASP.NET

Yanzu zaka iya tafiyar da lambar kuma bude shirinka zuwa: ... / cat / steve /

cat-steve-300x66 ASP.NET a kan OpenShift: Farawa a ASP.NET

Za mu ci gaba da ci gaba da cats, duk da haka yin hanya ga kowane mutum zai iya zama mummunan fushi, don haka yaya muke canza wannan. Zamu iya amfani da rikici ga sunan karewa wanda za a wuce azaman lamari. Don haka lambarmu na iya yanzu kama da wannan:

code-5-194x300 ASP.NET a kan OpenShift: Farawa a ASP.NET

Yanzu gudu lambar kuma kai tsaye ga mai bincike don: ... / cat? cat = lissafin sai me ... / cat? cat = steve

Yanzu muna da cats a cikin irin wannan hanya, duk da haka URL ɗin yana da zurfi. Wannan shi ne wurin da abubuwan ke faruwa ta hanyoyi ta hanyar shiga. Duk abin da muke buƙatar shi ne kaɗan canji zuwa lambar:

code-6-194x300 ASP.NET a kan OpenShift: Farawa a ASP.NET

Bugu da ƙari, yanzu za mu iya mayar da hankali ga yin amfani da: ... / cat / bill and ... / cat / steve.

Wannan shi ne na ɓangaren farko na wannan gabatarwa. Ta hanyar yin waɗannan hanyoyi guda biyu don ƙwararru da abin da suke faɗar, ka fara a yin sabis na yanar gizo na ASP.NET tare da kira biyu na API! Kashi na gaba zai tattauna yadda za a samo bayanai, da kuma yadda zangon ke aiki, yayin da muke ci gaba da girma.

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