0 ratings0% found this document useful (0 votes) 16 views15 pagesWebAPI_AspDotNet
Web Api Asp DotNet full notes
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
|
web Art ST 3% Programming Tntereace ott
oT Soffware Application 820 commu
nicahon aT Toterackon PRAT
web APL YH eramwork Technolog Fe
[5 car HE Develop att =e
web ARE websites, web Applicabon, windows
Application, console Applicakion , au Farmengo:
application Andvpid 70s. Gaming Bat doko,
provile POURS? ARAL.
\alel A pT
Wha} is web Aer? in Asp.Net
web Apr AT User Interface AAT ay Hay
Dela Provide RAT. ;
web APE Frontend Applicadron SR dada Ger
Beaty eer Database. MI Sag FAT
oF
Database re GET BAT HVOY— Frontend]
Al Send .
API class Bl / controller ST always APL Controler
class T Tnheriteq Sa
Aer controller HEF” oT Method clefine RATA
SWAT AcHon Method FeO: aT ATP
verbs decorated Bata.
HTTP Verbs :— RTTeGET, HTT PPosT , HTTP PUT ,
HITPDELETE , HTTPPATCH.
\What- is ToT 's ?
ToT SON] “TnferneF of Things AY oUTey IP Aclress
HUfOl~Toterneh Enablec] SRAATAS
TAL
Tors Gareth Taterek Cnabled pevies F
Communication ho kha.
Scanned with CamScannera a
for Ox = Smayt Bulbs, smart locks, sam Smart
wa}ch, Smart AC , SMart Fan, smarE Tv-
\hat is Restful Services?
|
2
ResE Stands for Represenfational state
Transfer.
nto duced by Roy Fielding in 2000-
Rest Architecture Rest Server
Resources “ll Access Provide HA —sarfet
clfent Resources Access HAN]:
4)
Resources FEU Acton Method saT
Controller E2T petine SRATH~ fox ex-Gebpala’
PostPataQ , PurDatat), DeleteDatat) SAI!
client F001 Afax call FN URL Through
APE Access HAT:
Birth Resource ET Unique URI's CURL) OR
Global FD's of Td eniity ALATA -
Rest Service. Data communication xaTsy
Text ; TS0N,; XML GAT Language “AT Use
PPAPAPTARARR AN RX aa ve
ral Sot FS on Aight weight “Sao
Poplar SyVe™
UDYPPPPPPPPPPLPR LPL
Scanned with CamScanner|
al
vd
| HTTP vech
—L_L—
[hak i SHIT? verbs and different Types? __|
ol
Hitp Verbs Different Types TAT TTP Request
Handle HOUMA Use PLAT.
Hite Verbs AcHon Method AT Apply HAF
SO) HAT Acton AT Ae BH STE
HTTP Verbs Apply PO SHAT.
D[Mve, web APE Framework toy HTTP
verbs use” alate]:
ZI
9
UIT PGET_— Hej Daya RET HOURS AMARA
ANY Data Buery Shang Parameter
Fhrough Pass FS SHAT. Body
Fhrough Dala Support HIT aer
) HTTP PosT —
Bata Server @W Post H ETT} use
RATT OT Query Shing a
Body. Sel through eda Past PS
Sha). Post new resource Sata
Save FROM ATR ATA >
iL rrp put - Per ST. existing Regource 7 dota yr
update HROUMATSY ATRAT- SA
data query sting ST body
Pheough Pass HD CHAT
PUTTS RNS R EMRE RE aay
=
y arr LetTe - Resource/data Aefefe HLT
A Query
; a
Shing Fhrough PART AR
zgats
Trey aya fartial Resource update
FITUTTL
Scanned with CamScanneriE
=
| Difference bebween PUT ctnd Porch = ere
~ a
PUT PATCH es
JI por FTES) Single Pred ast PATCH FEAT Figlfes
updata AER sea aa upeele MRR eS
Sorel) Freld <1 clecta Pass HET Taga
Spray ster aT Column al data
bua:
PRT objed update ATR? eae BS
STAY For eae
First_oame -
LPO RAL L
Parcameber Bin: Ving 2
a
confrolier IT Action Method AT Hh AT
Gey Parameter SIO Define HS THT
Parameter Pamihive Mall complex Type
SRK aA So Parameler STIOT
Buery Shing TAT Body through Bind
ab Shay
Paimifive type FEO THE, bool , double ,
dokehme, detimal, staeq 6 eT. Tay ®
Simple Type SET aT a ature
PRP:
di
3) complex “Ty pe FEOTY TT clotaly pe wer
Single value store ET TAT okjed-
Type HO AAT Primibive alata type
EON.
PRAPL.
PPPP.
nT SIRF] value store STAT for ex:
Arroy 4 classes, objects -
Public class Student f
~publfe int SkudenttD fgets sets}
|_ pul te string _student-oame _§ gets setst
public string Gender {get seh}
ad DAPPP
J
Scanned with CamScanner—
by defaulF Parameber binding Tey Gaer
‘| STIS AcHon method AT Simple CPamifve)
type Paramefer SRT AT Web npr
Framwork by default Guery shang FET
data Search hq 2 AX “complex ¥5re
BRIT AX by default body Hey tata
Search hx:
Default Parameter Binding Rule i=
GET Primitive Type NA
Complex Ty pe
DELETE Peienitive Type | NA
Complex Type |
| BE SRRRART LA BL
Pur Pri mitive Type Carne’ eaTy pe.
PATCH LPeimibive Type | Complex
Scanned with CamScannerff
Wrage
Frror Body aed Freon —Usei ____________»
en er 7
HTreaqer SMO HTT PpeLete ASL sit complex ™
[Type URL Throug rom Ur] pF
4
a Attribuke Pavamefer “AY TAT Défine Ss
| [Prom Bodg] Athabule :- Hitprest . HrTepuT SA?)
FRAT. =
AVUN
HITPPATCH AX KTEON MAb AT FH
Soule Fype SATO GH complex Fype fecal
TR Simple Tope AF Ribare Fez) med
at ay TIO) [eromUri) Toy complex
type FA method AT SVT LeromBod y7
a EA. Avis APE AT Performance
Increase €Il “HRT APE by deFoult
APRA
behowioax, sim ple and complex Behaviour
ae aver
‘i
TEromUri] READE Complex Hype TRC
Guery Shing Through ForceFully S{OLRAT
AVIRA.
[From Body] Rei bae Sines Fyre body
Through ForceFally PO TARA.
Lbadell
: Pe le t=
. . H a] F
og agile a
é
yRPP
Caniprost]
public student task Cama] csng tame)
L
7
auasviv bea sis
Scanned with CamScannerWada
Rox Stands for Asynchronous javascript and 4ML
Ajor ST Background HEH Server database [am
toad AST web Page AAT tisploy HY i
use WITT.
© \
Rex See web Page wWeload et atel~ Gar
wl evenk cat] STH] Se. edery code cxeuste
+ T Background AT server AT re yes
ST SATOT Background ATT ofa ajax af
receive €TGT Sadr webpage A Bind Slat
ASPONET Wee oT “aspx Page Server “1
Submit 14. Vacfucing ATML tags, ASPNET
TTT eae
controlsy, Tgpery code everyfhing . bub ajax
cay He FAT Page submit AT €Iq™
Lally Asitcxonouis Calf
| n
a Page reload oT IAT Ha request Background
AN send nt HRT Background ATT Receive.
er
Aéyachronoas cal EN Loprocess web peje UE
AAT other operofion PRAIRTAT available SRP
SEO Page Freeze at ates
Whol is __Syachronous call?
ee Server Fequesk inprocss OMCIPT web page |
operations Stop CINTA AUT ATIYT response
complete Wel ATIUT Page Creeze VET
Scanned with CamScannerDy wd
r
$+ ajax Cf
type +
ult
content Type!
data:
datatype:
Success + function (result) i 4,
2)
3)
Failure : Funch'on Cerror)f 7
async !
3
Delails :—
Tupe = HTTP Verbs (GET, Post , PUT, DELETE)
Dest web service | web API URL
content Type =a) doda receive 2TUAT SET
nytt
ATA Type. eq: ISON, Mc, TerE
Data =ar dlafa . aT celected Type AEA send
ARIAT, ATE AT deka:
& Ison Formok ARNT data, Text or
XML format TAT data,
4)
8)
AataTy pe. wal dafa Server “IT send PT
Be TAT Ty pe eq. Ison , XML, Text-
Success = APL success ZIRT AT Function
response TINT
Fajure = Aer HEY error SUIRT AT -Eunchion
fi response HTT:
acync= C1 UG Boolean Property RT.
by default true BT
2 alain a dala BRAMARAPDMAAPAAADAAAAMAR AR Ago oe sad
Scanned with CamScanner—LiL
* | CoRS in ASP/NET web APT
D[ CORS Stands for Cross Oviqin Resource sheen
Dl cors mechanism WET AAT oman ATEAy =
welo APE ASAI oF restted SANA. ATray
AT aifferent clomain AEA Resource shearing
cow beAT
Ilha js _same axigin Policy 2
U[ Srouser HT Same domain HEQRl Ajax requesk
eeu XJ
3)
For Secustty Purpose brouser Aqox request
atferent ongin Fea yestoet Hey ANAT
oxiqin PolPery TOA
What is same ond litterent Domain ?
Same Domain 2—
google com AAAA QeoglecomJAPE Access
ATLOT
Different Dorrain y=
€q- Amazon -com PAY com APE call
HOT.
4
TT ATTRAATT APT UT Access differen! domain
HEY Sa SS aR aE Proje TER
BTU COPS SeFtag enable te Trey
step
FITTV ATER EERE URL UUL EDU Ub Ubu ues eEK eK Ererrren
Scanned with CamScanner| Enable cows attribute class- __ee!
al Attrioat class Se. PTT G Parameler
SRA
SY
=
1) Omains 2 FT > BATTOT Tomaun mans ton =
Naval RE STRAT APE aT request =
STOTT =
ey ANAEN SATFOT (C3) Comma oT maltple URC Ome
=
Ral Ss SHAT a =
2) AU domain zs} EET =
=
Ti) Request Reader 2- -
) ST Request Header measian FATT -
2) * FECT all Request Heacler
ii) HTTP METHODS 2 —
) Http method Allow AROMAS — AT ay
2) * ONT autre method,
D SAY AMT C5) Comma at multiple
meods Sgperate HD eth
*. SPT Enable Coks SarporE @ (evel MT
a eThat
1) Globol Jeve) :— AITEN webAPr-confiy.cs
He Setting Herel) Ai
€4' udng Custom: tleb- HTTP. CoRs.
public static void Register CHITPCantiq umahion
: config)
Enable(orsAtythule cors = new EnableCoreAHyhid
(urn, "GET, PosT"), ~Fue2)
confi: Enable Cong Ccoxs) + __ ~
4 J
Scanned with CamScanner2) Combeller level --
Nlimited to confrellers only:
—_
[EtableCors Caxigin : “URL", headers: "*",
methods + ie "D)
postal \ Value sController + ApiCont oller
des
3) Acton level =
i) &l setting Raton level sehr cpable ey
Scanned with CamScanner| ale APT Hasking on ITs Ss
l\wlhat ic TIS Server ?
)
TTS sfonde for Interne? Information Server.
2)
@ GH Popular, Server Ste oT Hashing Sic SY
=
deple ment =e} Use SIT
Spa ae ae base Applicaton web APE —
Kost 5 that =
mye Server toi ndows operoak ng system aay 3
goork Hed
s) a Server clot Net Apelicatten hosing ad
RTT
al ays
weet User] clrenk req aesh PRAT
SITY
Request Accept HHA Process
Response Send
EES server HEA Te NET Processing
engine Ale of ASPNET eq uest
Randle 27:
Scanned with CamScannereee
Swagger Copen Aer)
\
| Swagger Tangooge agnostic Spec ification ATE
of Rest APE describe HVAT -
2) Swagger TIAMAT APT docament create HLOUAwS
Help ART \
3) Swagger APT testing Ae Help RT
2)[ API testing “Tel Sxef Party feol (Postmen ) use
POUT ET STTOT Prayect AEM Swagger install
aS Ose hS TAT
XN . \ 7
Swagger EY Aer aq defei[s show ©! c
InstallaHen process :—
f
S)
Upright click on APE profet
2) goto ret F NaGel package
B)] elrek on Browse
5 Find Search =, Swasbbuckle
Sy and inctal iE
note:— once installed you will cee «wager:
config. cs File in App Start Folder.
wun the project and type below URt
URL = Domain swagger
Bema UT TTT TT eee
Scanned with CamScannerDlHTTP segues! TF 5 Types STA
a ~
2) ae code EAT vequest success Tat
\ 4
A
HItp code ¢! OH namecc value SE aT!
Server SATION client FE informedion exchange
OURS! Use, Stet
aT
att é TATA
\
1) Tnformatione] response = 100 to 1494
ii) Successhul response = 260 to 244
TE Ssuccessfal Fesponses FRTATA-
200 = Ok
20) = created _
202= Accepted
204 = mo cenfenk
iti) Reclireck messages = 300 +o 344
| 408 = tine ovt _ _
B07 = temporary redirect =
308 = permanent vreclirech
iv) Clrenl error response = 4oo to 444-
ayer Clienk side (aguery) Feat error
WaT eesponses STAT:
Hoo = Bad Request
hol = Unkathonzed
Goa = Payment Required
403 = Forbidden
4oy = not Found _
Hos = medfiod not alowed
406 = not acceptable
Scanned with CamScanner=e
vy) Server Error response = S0Q to 54]
Server s(de ot AY Grror Bef aX Soo Series
ervor UAT:
\
Server Sjde FEOTS ear code Tey Apa Het
Controller AE2F SOT erroy.
500 = Ainternal Server Error
sol = not implemented
soz = Bad Gebway
503 = Service anccyat lable
Sok = qetway Hrneout-
ESSE TREO ERECT L LA
a3
Scanned with CamScanner