ASP.NET Web API Interview Questions and Answers (7) - Page 1

What is difference between ASP.NET Web API and WCF?

1) WCF is unified programming model for building reliable/secure Service oriented application which is integrate across platforms and accessible over a variety of transports protocol (TCP,MSMQ,UDP etc).

2) WCF supports Request-Reply/One Way/Duplex message exchange patterns.

3) Supports WS-* standards like Reliable Messaging, Transactions, Message Security.
----------------------------------------------------------
1) ASP.Net Web API is a framework that makes it easy to build HTTP services that are accessible from a wide variety of clients(browser, mobile devices etc)

2)Web API is only supports request/response pattern.

3)No support for Reliable Messaging or Transactions.
How to implement multiple inhertiance in C#

NOTE: This is objective type question, Please click question title for correct answer.
How to resolve the Cross Origin Resource Sharing (CORS) issue in Asp.net WebAPI?

Cross Origin Resource Sharing (CORS) allows the server to share the resources being requested by the client application by overcoming the problem of same-origin policy. It is a very common requirement while developing the Asp.net WebAPI applications at the time of deployment where an external client application will try to access the resources by sitting at a different domain where as the resources are available at some other domain and that causes the root issue. CORS overcomes this issue by providing the needed permission for accessing the different domains. The below step will tell us how to do so -


Step a)

Use NuGet Package manager console and add CORS library to the project

e.g.
Install-Package Microsoft.AspNet.WebAPI.Cors -Version 5.0.1


Step b)

Open the file App_Start/WebApiConfig.cs and add the following code to the WebApiConfig.cs method

using System;	


//add the below namespaces

using System.Web.Http;
using System.Web.Http.Cors;

namespace MyWebAPI
{
public static class WebApiConfig
{
public static void Register(HttpConfiguration config)
{
// Web API configuration and services

//add the below lines

config.EnableCors();
config.EnableCors(new EnableCorsAttribute("*", "*", "*"));

.....................................
.....................................

}
}
}

Which among the below HTTP verbs will allow to create a new content of a resource?

NOTE: This is objective type question, Please click question title for correct answer.
Which among the below HTTP verbs will allow to modify the content of a resource?

NOTE: This is objective type question, Please click question title for correct answer.
Which among the below HTTP verbs will allow to remove the content of a resource?

NOTE: This is objective type question, Please click question title for correct answer.
How to ensure that ASP.NET Web API returns only JSON data ?

NOTE: This is objective type question, Please click question title for correct answer.
Found this useful, bookmark this page to the blog or social networking websites. Page copy protected against web site content infringement by Copyscape

 Interview Questions and Answers Categories