ASP.NET MVC Interview questions: - What is WebAPI in MVC ?
What is "WebAPI"?
For satisfying the broad range of client "REST" was the proposed approach. You can read more about "REST" from WCF chapter.
"WebAPI" is the technology by which you can expose data over HTTP following REST principles.
But WCF SOAP also does the same thing, so how does "WebAPI" differ?
With WCF also you can implement REST,So why "WebAPI"?
WCF was brought in to implement SOA, never the intention was to implement REST."WebAPI'" is built from scratch and the only goal is to create HTTP services using REST.
How to implement "WebAPI" in MVC?
Below are the steps to implement "webAPI" :-
Step1:-Create the project using the "WebAPI" template.
Step 2:- Once you have created the project you will notice that the controller now inherits from "ApiController" and you can now implement "post","get","put" and "delete" methods of HTTP protocol.
Step 3:-If you make a HTTP GET call you should get the below results.
MVC (Model view controller) interview question References for further reading:-
- Awesome MVC interview question how can we restrict HTTP POST and HTTP GET.
- You can refer this exhaustive book on c# and .NET interview questions and answers published by BPB publications written byauthor Mr. ShivprasadKoirala.
- MVC interview question :- Difference between tempdata,viewdata and viewbag
- Fresher to Model view controller (MVC) start from here Learn MVC step by step.
- This question is taken from MVC interview question prepared by www.questpond.com.