YouTube Interview Questions Flashcards

1
Q

What is REST?

A

REST stands for REpresentation State Transfer.

Server responds to Create Read Update and Delete request.

All server endpoints will be an access point to a resource.

This pattern treats every service as a reource and we can access the reourse using CRUD.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is ASP.NET Web API?

A

Its is a framework used to develop HTTP based API.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a RESTFul service?

A

It is a pattern to develop a HTTP API.

It should follow:

Client- sevrer isolation.
Stateless
Cacheable
Uniform Interface.
Code-on-Demand.
Layered architecture.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the advantages of using ASP.NET Web API?

A

TB

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is CORS?

A

We host a web API in a server, and Browser security prevents a web page from making requests to a different domain than the one that served the web page. This restriction is called the same-origin policy. The same-origin policy prevents a malicious site from reading sensitive data from another site.

To Enable CORS we have to configure it in service.AddCORS();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is routing?

A

When a request arrives from a client (browser or any application) arrives to our application, it is the controller which responds to the request. The incoming URL is mapped to the action method. This mapping is done by the routing rules defined by our application.

For example, www.testurl.info/order/1

order is mapped to the controller and 1 is mapped to the id.

In conventional routing, the application uses route template which is defined in the configuration in the middleware.

But in attribute routing, we use Route attribute. this can be applied to either action method or controller.

We can also use token in attribute routing :
[Route(“[controller]/[action]”)]

the Index method templates must prepend / or ~/ to the route templates. Route templates applied to an action that begin with / or ~/ don’t get combined with route templates applied to the controller.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is Async Controllers?

A

WHen a request comes to the

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Action filters?

A

Action filter allows us to execute custom code either just before the action method is executed or after the action method is executed.

There are 4 types of action filter:

a. Authorization Filter: Implements IAuthorizeFilter. This filter executes before any other filter. We use [Authorize] attribute.
b. Action Filters: Implements IActionFilter. We have to override OnActionExecuting() and OnActionExecuted().
c. Result Filter: Implements IResultFilter. On ResultExecuting and OnResultExecuted().
d. Exception filter: Implements IExceptionFilter. Overrides OnException method .

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is HTTPResponseMessage and IHTTPActionResult?

A

HTTPResponseMessage was introduced in web APiI 1 and IHTTPActionResult was introduced in Web API 2. The later one provide code readability.

Example:

HTTPResponseMessage Get()
{
//error

Request.CreateErrorResponse(HttpStatusCode.NotFound, “Student Not found)”

return Request.CreateResponse(HTTPStatusCode.OK, STudent);
}

IHttpActionResult Get()
{
//error

return NotFound();

or//

Content(HttpStatucCOde.NotFound, “not found”);

   return Ok(STudent);
}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can we restrict access to methods with specific HTTP verbs

A

use attribute such as

[HttpPost]

void Post(Student stu)
{}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly