Qhov txawv ntawm Server.Transfer thiab Teb.Redirect

Qhov txawv ntawm Server.Transfer thiab Teb.Redirect
Qhov txawv ntawm Server.Transfer thiab Teb.Redirect

Video: Qhov txawv ntawm Server.Transfer thiab Teb.Redirect

Video: Qhov txawv ntawm Server.Transfer thiab Teb.Redirect
Video: Tshuaj theem vim li cas thiaj tau nqi ?/ Siv kho mob dab tsi?/paris polyphylla use for? 2024, Hlis ntuj nqeg
Anonim

Server. Transfer vs Response. Redirect

Server thiab Teb ob qho tib si yog cov khoom hauv ASP. NET. Server object muab txoj hauv kev thiab cov khoom rau ntau yam dej num ntsig txog lub server. Hloov pauv yog ib txoj hauv kev ntawm cov khoom Server thiab nws xa cov ntaub ntawv ntawm lub xeev tam sim no mus rau lwm cov ntaub ntawv.asp rau kev ua haujlwm. Cov khoom teb piav qhia txog txoj hauv kev thiab cov khoom muaj feem cuam tshuam rau lub server cov lus teb. Redirect yog ib txoj kev ntawm cov khoom teb thiab nws xa lus mus rau qhov browser ua rau nws txuas mus rau qhov sib txawv URL. Txawm hais tias ob qho tib si Server. Transfer thiab Response. Redirect tuaj yeem siv los hloov cov neeg siv los ntawm ib nplooj ntawv mus rau lwm qhov, lawv txawv ntawm qhov lawv ua tau zoo li cas.

Kev teb yog dab tsi. Redirect?

Redirect is a method in the Response object. Thaum txoj kev teb raug hu, nws xa HTTP code 302 thiab URL ntawm nplooj ntawv thov mus rau cov neeg siv browser. HTTP code 302 qhia rau cov neeg siv 'browser tias cov ntaub ntawv thov nyob rau hauv qhov sib txawv URL. Thaum tus browser tau txais cov lej, nws qhib cov peev txheej hauv qhov chaw tshiab. Cov nplooj ntawv web thov tuaj yeem nyob ntawm tib lub server raws li nplooj ntawv uas muaj cov lus thov lossis nws tuaj yeem nyob hauv qee lwm tus neeg rau zaub mov. Thaum thov ib nplooj ntawv web uas nyob ntawm tib lub server raws li nplooj ntawv tam sim no, cov lus teb tuaj yeem siv raws li hauv qab no:

Response. Redirect(“nextPage.html”);

Thaum thov ib nplooj ntawv web uas nyob ntawm lwm tus neeg rau zaub mov, cov lus teb tuaj yeem siv raws li hauv qab no:

Response. Redirect(“https://www.newServer.com/newPage.aspx”);

Dab tsi yog Server. Transfer?

Raws li tau hais ua ntej, Hloov pauv yog ib txoj hauv kev ntawm Cov Khoom Muag Khoom. Thaum hu ua Transfer method, thawj qhov kev thov raug hloov pauv mus rau lwm nplooj ntawv hauv tib lub server. Thaum nplooj ntawv tshiab thov siv Server. Transfer, URL qhia hauv cov neeg siv lub vev xaib tsis hloov pauv. Qhov no yog vim qhov hloov pauv tshwm sim hauv server sab thiab browser tsis muaj kev paub txog kev hloov pauv. Los ntawm kev siv lub thib ob overload rau Server. Transfer (txoj txoj kab, bool preserveForm) thiab teeb tsa qhov thib ob parameter raws li qhov tseeb, tshaj tawm daim ntawv hloov pauv thiab cov kab lus nug tuaj yeem ua rau nplooj ntawv thib ob.

Dab tsi yog qhov txawv ntawm Server. Transfer thiab Response. Redirect?

Txawm tias ob qho tib si Server. Transfer thiab Response. Redirect tuaj yeem siv los hloov tus neeg siv los ntawm ib nplooj ntawv mus rau lwm qhov, muaj qee qhov sib txawv ntawm ob txoj hauv kev. Dhau li ntawm qhov pom tseeb syntactical sib txawv, Response. Redirect ua ib ncig mus rau lub server, thaum Server. Transfer hloov lub tsom xam ntawm lub web server mus rau lwm lub web page. Yog li ntawd, los ntawm kev siv Server. Transfer, server cov peev txheej tuaj yeem khaws cia. Ntawm qhov tod tes, Response. Redirect tuaj yeem siv los hloov tus neeg siv mus rau nplooj ntawv web hauv lwm tus neeg rau zaub mov whereas Server. Transfer tsuas yog siv los hloov tus neeg siv mus rau nplooj ntawv web ntawm tib lub server. Tsis tas li ntawd los ntawm kev siv Server. Transfer, cov khoom ntawm nplooj ntawv dhau los tuaj yeem nkag tau los ntawm nplooj ntawv tshiab tab sis qhov no tsis tuaj yeem nrog Response. Redirect. Tsis tas li ntawd, Response. Redirect hloov qhov URL hauv qhov chaw nyob bar ntawm qhov browser thaum nplooj ntawv tshiab nkag tab sis thaum siv Server. Transfer tus thawj URL yog khaws cia thiab cov ntsiab lus ntawm nplooj ntawv tsuas yog hloov. Yog li tus neeg siv tsis tuaj yeem siv nws los bookmark nplooj ntawv tshiab.

Pom zoo: