Q1. What is content negotiation in web api?
Q2. Name one tool available to test WEBAPI?
Q3. What is OWIN hosting in WEBAPI?
Q4. Advantages of webapi 2/3 over WCF?
Q5. How routing is done in WEB API?
--------------------------------------------------------------------------------------------------------------------------
Q1. What is content negotiation in web api?
Answer:
Q2. Name one tool available to test WEBAPI?
Q3. What is OWIN hosting in WEBAPI?
Q4. Advantages of webapi 2/3 over WCF?
Q5. How routing is done in WEB API?
--------------------------------------------------------------------------------------------------------------------------
Q1. What is content negotiation in web api?
Answer:
Accept: in header is what content negotiation works on.
Some client machines want data in normal HTML format and some in normal text format. Others need the JSON format and still others in XML format.
The formal definition of Content Negotiation as “the process of selecting the best representation for a given response when there are multiple representations available”.
Now, the fact should be clear, “Content Negotiation” means the client and server can negotiate. It’s not always possible for the server to return data in the requested format
The question is, how does the Web API know what the clinet expects? By checking below the header of the request object.
1) Content-type: data type in which request will go from UI. eg post request
2) Accept: The acceptable media types for the response, such as “application/json,” “application/xml,” or a custom media type such as "application/vnd.example+xml".
3) Accept-Charset: The acceptable character sets, such as UTF-8 or ISO 8859-1.
4) Accept-Encoding: The acceptable content encodings, such as gzip.
5) Accept-Language: The preferred natural language, such as “en-us”.
https://www.c-sharpcorner.com/UploadFile/dacca2/understand-content-negotiation-in-web-api/
--------------------------------------------------------------------------------------------------------------------------
Q2. Name one tool available to test WEBAPI?
Answer:
Postman
--------------------------------------------------------------------------------------------------------------------------
Q3. What is OWIN hosting in WEBAPI?
Answer:
Open Web Interface for .NET (OWIN) decouples the web application from the server, which makes OWIN ideal for self-hosting a web application in your own process, outside of IIS
Q4. Advantages of webapi 2/3 over WCF?
Answer:
Read WebAPI #25 also
- Webapi is Restful http calls while WCF is SOAP based xml calls. thus webapi is lighter.
- Comparatively WCF require more tedious and extensive configurations.
- Webapi usually has broad ranges of clients like browsers, mobiles phones, tablets, iPhone etc.
Q5. How routing is done in WEB API?
Answer:
Routing is possible in two ways in web api.
- by defining Routing in WebApiConfig.cs class file.
- by attribute routing.
- We also have route prefix option at controller level. [RoutePrefix(“reviews”)] . Which is ultimately part of attribute routing.
No comments:
Post a Comment