blog

qtq80-dp1eqm
16 Mar 2017

ASP.NET na OpenShift: Ịmalite na ASP.NET

Kedu ihe mere Okwu Mmalite na ASP.NET na OpenShift?

Na-eme ASP.NET mmepe tinye n'ọrụ OpenShift, M chọpụtara na a ole na ole Nkuzi si n'ebe maka mmalite na ASP.NET bụ

a) oke uche na-ama jijiji, na

b) agabigala ihe omuma nke ot'u o si aru

N'ọnọdụ ga-eji ASP.NET mee ihe na OpenShift, ị ga-enwe ike ịghọta ya!

N'ime nkwekọrịta nkuzi ntụziaka a, m ga-awụli elu na ohere iji nye gị nghọta dị mkpa banyere otú ASP.NET si arụ ọrụ na ihe ị na-eme tupu ịmalite itinye ọrụ gị na OpenShift. Anyị ga-enweta nke ahụ n'isiokwu n'egbughị oge.

Na akụkụ 1 na 2 nke mmezi ntụziaka a, m ga-aga n'ihu ngwa ngwa site na itinye ntanetịime na Mpaghara Visual Studio Community 2015. Nke a pụtara na ọ ga-abụ maka Windows na nke a. N'ọnọdụ ọ bụla, Aga m agbago elu karịa na ime ihe niile na-enweghị nhazi na Visual Studio Code na ịme ihe mgbe mmechara ihe ngosi gasịrị, nke ga-aba uru na Linux ma ọ bụ Mac na mgbakwunye Windows. Ọ bụrụ na ị naghị eji Windows, ị nwere ike ịnweta n'ọnọdụ ọ bụla na akụkụ 1 na 2 ka ha nweta echiche zuru ezu banyere otu esi eme nkwụsị REST na NET Isi.

Anyị kwesịrị ịmalite!

Nkebi nke 1 - Ịtọlite ​​ọrụ ASP

Ị ga-amalite site n'iji ọrụ ASP bụ isi na-eji Njikwa. Achọrọ m iji hụ na ị hụrụ otú ndị njikwa na-arụ ọrụ tupu ha agafe MVC kpamkpam.

Mee gị ọrụ

Na Visual Studio (M tinye n'ọrụ Community Edition 2015) pịa Njikwa na emesia New Project.

N'okpuru Ụkpụrụ -> Anya C # -> Nhazi weebụ, họrọ ASP.NET Core Web Application (.NET Core). O di oke nkpa ka i choputara NET Core ma obughi NET Framework dika nka bu akwukwo akwukwo NET.

nhazi 1024X552 ASP.NET na OpenShift: Ịmalite na ASP.NET

Tinye aha njirimara gị - nke a nwere ike ịbụ ihe ọ bụla ịchọrọ, na mmemme ntụziaka a, m ga-akpọ ya MeowWorld.

Dịka okwu a, ebe a ga-adị na Ntanetị Studio Studio Studio gị, ma egbula oge ịgbanwe nke a na ihe ị ga-eme ka ị ghara iji ohere ịkwado ihe omume nkụzi ahụ n'ebe ọzọ.

Anyị kwesịrị ime ndokwa ọzọ (azịza ya dị ka otu ụzọ na-ejide ọrụ dịgasị iche iche ị ga-arụ ọrụ na ya) na ọ dị anyị mkpa ịkpọ aha ihe ahụ.

Dị ka ihe dị mkpa, a na-akpọ ndokwa ahụ otu aka gị. Nke a dị mma, ya mere gbahapụ ya dịka ọ ga-adị. Mee nke ahụ, ọ bụ karịa ịnakwere ịmegharia aha ya ma ọ bụrụ na ị ga-enwe ike ịbanye na ohere.

Jide n'aka Na ịmepụta Ndekọ - achọpụta na ị ghọtara ihe ị na-eme, kama nke ahụ, ọ na-enyere gị aka idebe ihe edere.

Ị nwere ike n'otu aka ahụ Visual Studio na-eme ka ụlọ ahịa gọọmentị dị. Agaghị m eme nke ahụ dị ka nke a bụ mmega ahụ ntụziaka, ma maka ọnụ ọgụgụ ka ukwuu, ọ ga-adị gị mkpa.

Mgbe ị na-enwe afọ ojuju na nke ọ bụla n'ime ntọala, pịa OK ịkwaga na nhazi ndị a.

Kpido ihe ị ga-eme

N'ebe a, ị kwesịrị inwe nhọrọ atọ. Maka nkuzi ntụziaka a, ị ga-ahọrọ nhọrọ Web API. M ga-abanye na nke abụọ ahụ na nkuzi nkuzi n'ọdịnihu.

template-1-300X234 ASP.NET na OpenShift: Ịmalite na ASP.NET

Na ohere na ị ga - ezukọ ma na - agba ọsọ na oge a, ọ ga - emeghe windo mmemme (ma ọ bụ taabụ) ma were gị ... / mmemme interface / ụkpụrụ / - nke ga - egosi ụyọkọ JSON na - egosipụta nke a:

api-values-300x66 ASP.NET na OpenShift: Ịmalite na ASP.NET

Mechie usoro ihe omume gị ma hụ na ị kwụsịrị ịkwadoro site na ịpịpụta azụ na-acha uhie uhie (nke na-ekwu "Quit Debugging" mgbe ị na-akwagharị) na ihe mgbaru ọsọ ị nwere ike ịgbanwe ya.

MGBE onye na-achị gị

Na Nchọpụta Nchọpụta, gaa na Ngwọta Aha -> src -> Aha Project -> Njikwa -> ValuesController.cs ma mepee ya.

Hụ otú otu ụzọ ọ bụla nwere Http ... "àgwà metụtara ha (HttpGet, HttpPost, HttpPut, naHttpDelete). Nke a bụ usoro http - HttpGet` bụ ọsọ nke igwe ihe a na-eji mee ihe maka ịbịaru ibe weebụ. Enwere ike iziga nsogbu na usoro ọ bụla dị ka ịchọta ihe edemede (ma ọ bụ ihe ndekọ data - ọzọ na ụzọ gafere).

Right-Click na envelopu na-achịkwa ma mee ka otu klas ọzọ a na-akpọ CatController.

njikwa-300X162 ASP.NET na OpenShift: Ịmalite na ASP.NET

Tinye Microsoft Library nke Microsoft.AspNetCore.Mvc iji nyere aka mee ka koodu gị zuru oke.

Tinye usoro Meow nke a na klas gị:

code-2-254x300 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ugbu a gaa na koodu. Na mmemme gị, affix / cat / bill / to lochost: ##### ịhụ ọrụ gị na ndụ n'ezie.

feline-bill-300x66 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ị na-evolving HttpGet ("cat / bill") ka ị gụọ HttpGet ("cat / bill") ma gbanwee aha usoro ahụ site na "Yowl ()" iji mepee Bill Bill ().

Rịba ama na ọ bụghị aha onye nchịkwa ma ọ bụ usoro ahụ na-emetụta ụzọ. Ọ bụ omume ọ bụla iji mee ka ihe niile dabara, ma mee ka koodu ahụ dị ọhụrụ:

code-3-254x300 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ugbu a, lee ka anyị si agụnye cat ọzọ!

code-4-188x300 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ugbu a, ị nwere ike ịgba ọsọ koodu ma mepee usoro gị na: ... / cat / steve /

cat-steve-300x66 ASP.NET na OpenShift: Ịmalite na ASP.NET

Anyị nwere ike ịnọgide na-agụnye nwamba, ma na-eme usoro maka onye ọ bụla nwere ike ịme ka ọ bụrụ ihe mkpasu iwe, ya mere, olee otú anyị si agbanwe nke ahụ. Anyị nwere ike iji arụmụka maka aha pusi nke a ga-agafe dịka eriri ajụjụ. Ya mere koodu anyị nwere ike ugbu a yiri nke a:

code-5-194x300 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ugbu a, gaa koodu ahụ ma mee ka nchọgharị gị gaa: ... / cat? cat = ụgwọ Ọzọkwa ... / cat? cat = steve

Ugbu a, anyị nwere nwamba ahụ n'ụzọ yiri ya, Otú ọ dị URL ahụ dị mkpirikpi. Nke a bụ ebe ihe na-aga site n'okporo ụzọ na-abata. Ihe niile anyị chọrọ bụ obere mgbanwe na koodu:

code-6-194x300 ASP.NET na OpenShift: Ịmalite na ASP.NET

Ọzọkwa, ugbu a, anyị nwere ike backpedal iji tinye: ... / cat / bill and ... / cat / steve.

Nke ahụ bụ maka akụkụ mbụ nke ngosi a. N'ime ụzọ abụọ a maka nwamba na ihe ha na-ekwu, ị maliterela na-eme ka ọrụ ASP.NET jiri oku API abụọ! Ebe ọzọ m ga-esote ga-atụle ịbịakọta ma debe data, na otú sessions si arụ ọrụ, ka anyị na-eto eto.

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