Ø .NET version is released with some significant improvements
o .NET 1.0 - 2002 Initial version (1st release)
o .NET 1.1 - 2003 Update on 1.0, added provider for Oracle
o .NET 2.0 - 2005 Generics were introduced.
o .NET 3.0 - 2006 WPF, WCF, WF were introduced
o .NET3.5 - 2007 LINQ and ADO .NET Entity Framework
o .NET 4.0 - 2010 Dynamic support for languages and TPL (dynamic keyword introduced along with Task Parallel library )
o . NET 4.5 - 2012 Asynchronous programming support (async and await keyword introduced And Zip facility).
Ø What is basic authentication?
o Client send request with user credential in Authorization Header.
o Credential encrypted with Base 64 encoding and decoding.
o WWW-Authenticate response header indicates the Basic authentication.
Ø Disadvantage of Basic Authentication.
o User sends credential in each and every request so it wills possibility to steal user’s credential.
o It is implemented by Base 64 Algorithm so this is known algorithm in universal.
Ø What is JWT(Json Web Tokens) Token?
o JWT is providing secure data transmission between two parties.
o Auto generated signed token using mechanism like HMAC, RSA, ECDSA Algorithm.
Ø Advantage of JWT(Json Web Tokens)
o When it encoded size is smaller.
o Use Algorithm like HMAC,RSA,ECDSA for increase more security.
Ø Disadvantage of JWT?
o If a user account needs to be blocked or deactivated, the application will have to wait for the token to expire in order for the lockout to be fully effective.
o Real logout is not possible until token not expire.
o We could not manually extend expiry time of JWT token, so refresh token and reuse those token is not possible.
Ø What is ActionResult in MVC?
o MVC framework contains different result classes when any action returns a result.
Ø How many type of ActionResult?
o ViewResult – Return html and markup.
o EmptyResult – Return no response.
o ContentResult- Return string literal.
o RedirectToAction – Return on action method.
o FileContentResult/FilePathResult/FileStreamResult- Return the content of a file.
o JavaScriptResult – Return a JavaScript.
o JsonResult – Return Json.
o RedirectResult – Redirect on new URL.
o RedirectToRouteResult – Redirect on another action or another controller.
o PartialViewResult – Return HTML from partial view.
o HttpUnauthorizedResult – Return HTTP 403 Status.
Ø ASP.NET MVC Life cycle.
o First request URL check in to the routing table.
o If url found in the routing table, Routing engine forwards the request url to the corresponding IRouteHandler(default is MVCHandler) for that request.
o MVCHandler is responsible to call the controller using IControllerFactory instance.
o After controller instantiated, Controller's ActionInvoker identify which specific action to invoke on the controller.
o The action method process on request, prepare response data and returning a result according to their return result type (for return result type follow our question “How many type of ActionResult?”).
o View engine (IViewEngine interface) render those action data on view for UI purposes.
Ø What is routing in ASP.NET MVC?
o Routing is the pattern matching system, which matches the request URL into the routing table.
o If the request URL found into the routing table, forward those request to the MVC handler and initiate the request otherwise routing engine returns a 404 HTTP status code.
Ø Difference between ViewBag and ViewData in ASP.NET MVC.
ü Both are used for transfer data from controller to view.
ü ViewData is a Dictionary of objects and accessible by a string key
ü Ex. ViewData["Result"] = 1;
ü ViewBag is a dynamic type
ü Ex. ViewBag.Result=1
ü View bag is dynamic type so doesn’t require to typecasting.
ü View data requires typing casting for complex data type and also checking for null to avoid an error.
ü How to require typecasting let’s see with an example.
Controller:
List<string> l = new List<string>() { "1", "3" };
ViewBag.Result = l;
View:
@foreach (var item in ViewBag.Result)
{
<span>@item</span>
}
Controller:
List<string> l = new List<string>() { "1", "3" };
ViewData["Result"] = l;
View:
@foreach (var item in ViewData["Result"] as List<string>)
{
<span>@item</span>
}
Ø Different types of filters in .Net MVC.
ü Authorization
filters
·
Implements
the IAuthorizationFilter.
·
Used to
implement Authorization and authentication for controller actions
ü Action
Filters
·
Implements
the IActionFilter.
·
Perform
some operation or task before and after an action method executes.
ü Result
Filters
·
Implements
the IResultFilter.
·
Perform
some operation or task before or after the executions of the view.
ü Exception
Filters
·
Implements
the IExceptionFilter.
·
Perform
some operation or task when any unhandled error occurred during the ASP.NET MVC
pipeline.
Ø Is it possible to invoke Garbage Collector explicitly?
ü Yes using System.GC.Collect();
Next Recommended Article:
- When to use abstract class and interface in C#?
- Async and Await in C#
- Optimized top 2 ways to find 2nd or Nth highest salary in SQL Server.
- Different ways to remove or delete duplicate rows from a SQL Table.
- Top 100+ popular SQL Interview Questions and Answers Blog.
- Top 100+ popular C# Interview Questions and Answers.
- @Input, @Output decorator and EventEmitter class in Angular.
- Dependency Injection and types of dependency injection.
No comments:
Post a Comment