blog

qtq80-dp1eqm
16 MK 2017

ASP.NET i te OpenShift: Me timata i ASP.NET

He aha te Whakatairanga ki ASP.NET mo OpenShift?

I te hanga ASP.NET whanaketanga e whakamahi ana i OpenShift, kua kitea e ahau he torutoru nga akoranga kei reira mo te timatanga i te ASP.NET

a) he nui te whakaaro nui, a

b) kaua e whakawhiti i nga kaupapa o te pehea e mahi ai

I roto i te take ka whakamahi ASP.NET ki OpenShift, me whai kaha koe ki te mohio ki taua mea!

I roto i tenei whakaritenga mahi ako, ka peke ahau ki te waahi ki te homai ki a koe he tino waahi ki te mahi a ASP.NET me te aha e mahi ana koe i mua i te tukanga o to mahi ki OpenShift. Ka tae atu ki te tuhinga i roto i te tuhinga.

I roto i nga wahi 1 me 2 o tenei mahi ako, ka timata ahau ki te timata i te tere ma te whakamahi i nga taapiri i Visual Studio Community 2015. Ko te tikanga tenei mo Windows i tenei waahanga. I tetahi take, ka rere atu ahau ki raro ma te mahi i nga mea katoa kahore he mahinga i roto i Visual Studio Code i roto i te tango i muri i nga mahi ako, e whai hua ana ki a Linux, Mac ranei, me te tua atu o Windows. I te mea kaore koe i te whakamahi i te Windows, ka taea e koe i muri i muri i nga waahanga 1 me 2 kia whai whakaaro nui ki te mahi i te mutunga REST i roto i te NET Core.

Me timata tatou!

Wahanga 1 - Tautuhi i te Ratonga ASP

Ka timata koe ma te mahi i tetahi ratonga ASP taketake e whakamahi ana i te Kaiwhakahaere. Me whakarite kia kite koe i nga mahi a te Manahauturu i mua i te neke atu ki te MVC.

MAKE TAU PUTU

I roto i Visual Studio (kei te whakamahi ahau i te Community Edition 2015) ka pawhiria te File me te muri i te kaupapa hou.

I raro i nga Tātauira -> Visual C # -> Kaiwhakahaere Tukutuku, tīpako ASP.NET Utu Tukutuku (.NET Core). He mea nui kia whiriwhiria e koe te NET Core me te kore te .NET Framework kia rite ki tenei ko te wharepukapuka cross-stage .NET.

kaupapa-1024X552 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Tomohia to ingoa ingoa - koinei te mea e hiahia ana koe, i roto i tenei mahi ako ka karangatia ahau e MeowWorld.

I te mea ko tenei, kei roto i tenei kaitohutohu o te Whakahaere Studio Studio, engari kaore e whakaroa ki te whakarereke i tenei waahanga ka taea e koe te keto i te tupono ki te rokiroki i te mahi ako i tetahi atu wahi.

Me whakarite ano tetahi atu whakaritenga (he rite te whakautu ki tetahi waahanga e mau ana i nga mahi rereke e mahi tahi ana koe) me te waitohu ki te tohu i te mea whakarite.

I te mea ko te tikanga, ko te whakaritenga e whakahuatia ana kia rite ki to mahi. He ataahua tenei, na waiho kia waiho. Mehemea tera pea, ka nui noa atu te manako ki te whakaingoatia i te mea ka taea e koe te peke i te tupono ki te.

Kia mohiohia te Whakaritea o tetahi Whaiaronga - kaore he mea nui ki a koe mo te waahi ka mohio koe ki ta koe e mahi ana, engari he pai te mahi ki te pupuri i nga mea.

Ka taea hoki e koe te hanga Visual Studio ki te toa toa. Kaore au e mahi pera na te mea he mahi ako tenei, engari he nui ake te paanga, ka hiahia pea koe.

Ki te pai koe ki nga taangata katoa, pawhiria te OK hei neke ki runga i te waahanga e whai ake nei.

WHAKAMAHI I TO TEMPLATE

I konei ka tika kia toru nga whiringa. Mo tenei kaupapa ako, me whiriwhiri koe i te whiriwhiri API. Ka uru atu ahau ki etahi atu e rua me nga akoranga o mua.

tauira-1-300X234 ASP.NET i runga i OpenShift: Ka timata i ASP.NET

I te waahi ka kohikohi koe me te whakahaere i te kaupapa i tenei wa, ka whakatuwheratia he matapihi papatono (he ripa ranei) me te kawe ia koe ki te ... / atanga rautaki / uara / - ka whakaatu i te cluster JSON e whakaatu ana i tenei:

api-values-300x66 ASP.NET i runga i OpenShift: Tīmata i ASP.NET

Katia to maatau hōtaka me te whakarite kia mutu taau mahi ma te kapi i te hopu tapawha whero (e kiia ana ko "Quit Debugging" ka kati koe) me te kaupapa ka taea e koe te whakarereke.

Tuhinga o mua

I roto i te Solution Explorer, haere ki te Ingoa Whakaora -> src -> Ingoa Kaupapa -> Mana whakahaere -> ValuesController.cs ka whakatuwheratia.

Tirohia te pehea o nga tikanga katoa he Http ... "te tikanga e pa ana ki a ratou (HttpGet, HttpPost, HttpPut, aHttpDelete). Koinei te tikanga HTTP - HttpGet 'ko te rere o te mira kotahi whakamahia mo te tiki ki te whārangi tukutuku. Ka taea te whakawhitinga i nga whakawhitinga ki nga tikanga katoa hei paanga uiui (ko te raraunga akoranga - atu i nga huarahi i muri mai).

Pāwhiri-matau i te pouaka o nga kaiwhakahaere me te hanga i tetahi atu karapu ko CatController.

kaiwhakahaere-300X162 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Tāpirihia te whare Pukapuka Microsoft.AspNetCore.Mvc hei awhina i te pupuri i to waehere tika.

Tāpirihia te tikanga Meow e whai ake nei ki tō akomanga:

waehere-2-254X300 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Na ka rere i te waehere. I roto i to maatau hōtaka, whaaata / ngeru / putea / ki localhost: ##### kia kite i taau mahi i roto i te oranga.

feline-bill-300x66 ASP.NET i runga i OpenShift: Ka timata i ASP.NET

Kei te whanake koe i te HttpGet ("cat / bill") ki te tuhi i te HttpGet ("cat / bill") me te whakarereke i te ingoa o te tikanga mai i te raupapa poari "Yowl ()" hei whakatuwhera i te Pire Bill ().

Kia mohio koe kaore ano te ingoa o te kaiwhakahaere, te tikanga ranei e whai mana ki te ara. He mahi auau ki te whakaoti i nga mea katoa, no reira ka whakahou i te waehere:

waehere-3-254X300 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Na me pehea e uru atu ai tetahi atu cat!

waehere-4-188X300 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Na ka taea e koe te rere i te waehere me te whakatuwhera i to kaupapa ki: ... / cat / steve /

cat-steve-300X66 ASP.NET i te OpenShift: Me timata i ASP.NET

Ka taea e tatou te haere tonu me nga ngeru, engari ko te hanga i tetahi tikanga mo te katoa ka taea te whakakino tino, ka pehea e hurihia ai e tatou. Ka taea e tatou te whakamahi i te tautohetohe mo te ingoa o te ngeru ka paahitia hei raina uiui. Na to tatou waehere inaianei rite rite tenei:

waehere-5-194X300 ASP.NET i runga i OpenShift: Me timata i ASP.NET

Na whakahaere i te waehere me te whakatika i to rorohiko ki: ... / cat? cat = putea a ka ... / cat? cat = steve

Na, kei a matou nga ngeru i roto i te huarahi ano, engari he rereke te URL. Koinei te waahanga e haere ana na roto i nga huarahi. Ko nga mea katoa e hiahiatia ana he iti noa te huringa ki te waehere:

waehere-6-194X300 ASP.NET i runga i OpenShift: Me timata i ASP.NET

I tua atu, ka taea e tatou te hoki mai ki te whakamahi i: ... / cat / pire me te ... / cat / steve.

Koinei te mea mo te waahanga tuatahi o tenei whakaaturanga. I te hanga i enei huarahi e rua mo nga ngeru me ta ratou korero, kua timata koe ki te mahi i te ratonga tukutuku ASP.NET me nga piiraa API e rua! Ko taku pou e whai ake nei ka matapaki i te tango me te tautuhi i nga raraunga, me tehea o nga waahanga e mahi ana, ka tupu te tipu o te ngeru.

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