Difference in Controller and ControllerBase Class in

Controler.cs

A base class for an MVC controller with view support.

ControllerBase.cs

A base class for an MVC controller without view support.It is used on Web api in ASP .Net Core.

Following components don’t exist in ASP.NET Core:

1.ApiController class
2.System.Web.Http namespace
3.IHttpActionResult interface

What is Rest

Rest(Representational State Transfer) is a architectural pattern to develop a api in restful manner

1- Follow rest suggested uri pattern e.g http://ABC.com/api/manage-employee http://ABC.com/api/manage-employee/1

2- Follow respective HttpVerb for each action.

e.g.

[HttpGet] //for retrieve data http://ABC.com/api/manage-employee

[HttpPut] // for update http://ABC.com/api/manage-employee/1

3. It works over HTTP Protocol.

Use of out keyword in c#

The main use of out would be where your method needs to return more then one parameter.

See below example of TryParse Method

using System;

public class Example
{
public static void Main()
{
String[] values = { null, “160519”, “9432.0”, “16,667”,” -322 “, “+4302”, “(100);”, “01FA” };
foreach (var value in values)
{
int number;

bool success = Int32.TryParse(value, out number);
if (success)
{
Console.WriteLine(“Converted ‘{0}’ to {1}.”, value, number);
}
else
{
Console.WriteLine(“Attempted conversion of ‘{0}’ failed.”,
value ?? “<null>”);
}
}
}
}

 

When View Engine come into picture in MVC Lifecycle ?

When we are ready to render a view after execution of controller logic View Engine is involved.The execution of the View Result involves the selection of the appropriate View Engine to render the View Result. If ActionResult returns a ViewResult, execution pipeline selects appropriate ViewEngine to render ViewResult. It is taken care by view engine’s interface IviewEngine.

To improve performance we should remove all ViewEngine that is not needed.
protected void Application_Start()
{
ViewEngines.Engines.Clear();
ViewEngines.Engines.Add(new RazorViewEngine());
}