1. N-Tier :
N-tier architecture is also called multi-tier
architecture because the software is engineered to have th e processing, data
management, and presentation functions physically and logically
separated. That means that these different functions are hosted on
several machines
2.
What is MVC (Model view controller)?
Model–view–controller (MVC) is a software architectural
pattern for implementing user interfaces. It divides a given software
application into three interconnected parts, so as to separate internal
representation of information from the way that information is presented to or
accepted from the user.
MVC is a framework for building web applications using a MVC (Model View Controller) design:
MVC is a framework for building web applications using a MVC (Model View Controller) design:
- The Model represents the application
core (for instance a list of database records).
- The View displays the data
(the database records).
- The Controller handles the
input (to the database records).
3.
List out different return types of a controller action
method?
The base type of all these result types is ActionResult.
- ViewResult (View): This return type is used to return a webpage
from an action method.
- PartialviewResult
(Partialview): This return type is used
to send a part of a view which will be rendered in another view.
- RedirectResult (Redirect): This return type is used to redirect to any
other controller and action method depending on the URL.
- RedirectToRouteResult
(RedirectToAction, RedirectToRoute): This return type is used when we want to redirect to any
other action method.
- ContentResult (Content): This return type is used to return HTTP
content type like text/plain as the result of the action.
- jsonResult (json): This return type is used when we want to
return a JSON message.
- javascriptResult (javascript): This return type is used to return
JavaScript code that will run in browser.
- FileResult (File): This return type is used to send binary
output in response.
- EmptyResult: This return type is used to return
nothing (void) in the result.
4.
What is the difference between Temp data, View, and View Bag?
ViewData
- ViewData is used to pass
data from controller to view.
- It is derived from
ViewDataDictionary class.
- It is available for the
current request only.
- Requires typecasting for
complex data type and checks for null values to avoid error.
- If redirection occurs, then
its value becomes null.
ViewBag
- ViewBag is also used to pass
data from the controller to the respective view.
- ViewBag is a dynamic
property that takes advantage of the new dynamic features in C# 4.0
- It is also available for the
current request only.
- If redirection occurs, then
its value becomes null.
- Doesn’t require typecasting
for complex data type.
TempData
- TempData is derived from
TempDataDictionary class
- TempData is used to pass
data from the current request to the next request
- It keeps the information for
the time of an HTTP Request. This means only from one page to another. It
helps to maintain the data when we move from one controller to another
controller or from one action to another action
- It requires typecasting for
complex data type and checks for null values to avoid error. Generally, it
is used to store only one time messages like the error messages and
validation messages
5.
Explain what is the difference between View and Partial View?
A partial view is a chunk of HTML. Partial views can also be
returned directly from controller methods.
View:
- It contains the layout page.
- Before any view is rendered,
viewstart page is rendered.
- View might have markup tags
like body, html, head, title, meta etc.
- View is not lightweight as
compare to Partial View.
Partial View:
- It does not contain the
layout page.
- Partial view does not verify
for a viewstart.cshtml. We cannot put common code for a partial view
within the viewStart.cshtml page.
- Partial view is designed
specially to render within the view and just because of that it does not
consist any mark up.
- We can pass a regular view
to the RenderPartial method.
6.
Explain the concept of MVC Scaffolding?
ASP.NET Scaffolding is a code generation
framework for ASP.NET Web applications. Visual Studio 2013 includes
pre-installed code generators for MVC and Web API projects.
7.
What is Bundling and Minification in MVC?
Bundling and minification are two new
techniques introduced to improve request load time. It improves load time by
reducing the number of requests to the server and reducing the size of
requested assets (such as CSS and JavaScript).
Bundling: It lets us combine multiple JavaScript (.js) files or multiple cascading style sheet (.css) files so that they can be downloaded as a unit, rather than making individual HTTP requests.
Minification: It squeezes out whitespace and performs other types of compression to make the downloaded files as small as possible. At runtime, the process identifies the user agent, for example IE, Mozilla, etc. and then removes whatever is specific to Mozilla when the request comes from IE.
Bundling: It lets us combine multiple JavaScript (.js) files or multiple cascading style sheet (.css) files so that they can be downloaded as a unit, rather than making individual HTTP requests.
Minification: It squeezes out whitespace and performs other types of compression to make the downloaded files as small as possible. At runtime, the process identifies the user agent, for example IE, Mozilla, etc. and then removes whatever is specific to Mozilla when the request comes from IE.
8. What is meant by routing in MVC?
Routing is a
mechanism in MVC that decides which action method of a
controller class to execute. Without routing there's no way an
action method can be mapped. To a request. Routing is a part
of the MVC architecture so ASP.NET MVC supports
routing by default.
9. What is linq in mvc ?
Language-Integrated Query (LINQ) is a
powerful query language introduced with .Net 3.5 & Visual Studio
2008. LINQ can be used with C# or Visual Basic to query
different data sources.
10. How to call view from another view in
mvc4?
I have a view called
LoggedIn.cshtml
getting
called from LoggedInController
.
Inside the LoggedInView
I
have a PartialView called _LoggedInPartial
to
display the nav
bar containing different menus like Home, Profile,
etc.
11.
Service
Oriented Architecture
A
service-oriented architecture can be defined as a group of services, which
communicate with each other. The process of communication involves either
simple data passing or it could involve two or more services coordinating some
activity. Some means of connecting services to each other is needed.
Benefits
- It is mainly for scalability
and better performance.
- An application wants to use
some of the services provided by for other enterprises.
12. Object-Oriented
Architecture c#
C# provides full support for object-oriented programming including
encapsulation, inheritance, and polymorphism.
Encapsulation means that
a group of related properties, methods, and other members are treated as a
single unit or object.
Inheritance describes
the ability to create new classes based on an existing class.
Polymorphism means that
you can have multiple classes that can be used interchangeably, even though
each class implements the same properties or methods in different ways.
13. ViewState
ViewState allows ASP.NET to repopulate form
fields on each postback to the server, making sure that a form is not
automatically cleared when the user hits the submit button.
14. Difference between stored procedure
and function
a.
Function must return a value but in Stored Procedure
it is optional( Procedure can return zero or n values).
b.
Functions can have only input parameters for it
whereas Procedures can have input/output parameters .
c.
Functions can be called from Procedure whereas
Procedures cannot be called from Function.
15. What is ViewStart?
Razor View Engine introduced a new layout named _ViewStart
which is applied on all view automatically. Razor View Engine firstly executes
the _ViewStart and then start rendering the other view and merges them.
16. Explain in which
assembly is the MVC framework is defined?
The MVC framework is defined in System.Web.Mvc.
17. Service-Oriented Architecture
(SOA) Definition ?
A service-oriented architecture is essentially a
collection of services. These services communicate with each other. The
communication can involve either simple data passing or it could involve two or
more services coordinating some activity. Some means of connecting services to
each other is needed.
Service-oriented architectures are not a new
thing. The first service-oriented architecture for many people in the past was
with the use DCOM or Object Request Brokers (ORBs) based on the CORBA
specification. For more on DCOM and CORBA, see Prior Service-Oriented Architectures.
Service-oriented architecture (SOA) is an evolution of distributed
computing based on the request/reply design paradigm for synchronous and
asynchronous applications. An application's business logic or individual
functions are modularized and presented as services for consumer/client
applications.
18. Object-Oriented Architecture ?
Object Oriented Architecture is an important concept for
developing the software. It is a design paradigm based on the division of
responsibilities for an application or system into individual reusable and
self-sufficient objects. The popular approach of object-oriented design is to
view a software system as a collection of entities known as objects. Object
oriented is based on modeling real-world objects.
Advantages of
Object-Oriented Architecture
·
Object-Oriented
architecture maps the application to real world objects for making it more
understandable.
·
It is
easy to maintain and improves the quality of the system due to program reuse.
·
This
architecture provides reusability through polymorphism and abstraction.
·
It
has ability to manage the errors during execution. (Robustness)
·
It
has ability to extend new functionality and does not affected on the system.
·
It
improves testability through encapsulation.
·
Object-Oriented
architecture reduces the development time and cost.
Disadvantages of
Object-Oriented Architecture
·
Object-Oriented
architecture has difficulty to determine all the necessary classes and objects
required for a system.
·
It is
difficult to complete a solution within estimated time and budget because
object-oriented architecture offers new kind of project management.
·
This
methodology do not lead to successful reuse on a large scale without an
explicit reuse procedure.
Object Oriented Concepts
Object-Oriented architecture views a system as a series of cooperating
objects, instead of a set of routines or procedural instructions. It is a
significant methodology for the development of any software.
19. Polymorphism?
Introduction
Polymorphism is a Greek word meaning "one name many
forms". In other words, one object has many forms or has one name with
multiple functionalities. "Poly" means many and "morph"
means forms. Polymorphism provides the ability to class multiple
implementations with the same name. It is one principle concept in Object Oriented
Programming after encapsulation and inheritance.
Types of Polymorphism
There are basically the following two types of polymorphism in
C#:
- Static
/ Compile Time Polymorphism.
- Dynamic
/ Runtime Polymorphism.
Static or Compile Time Polymorphism
It is also known as Early Binding. Method overloading is an
example of Static Polymorphism. In Overloading, the method / function has the
same name but different signatures. It is also known as Compile Time
Polymorphism because the decision of which method is to be called is made at
compile time. Overloading is the concept in which method names are the same
with a different set of parameters.
Here the compiler checks the number of parameters passed and the type of parameter and make the decision of which method to call and it throw an error if no matching method is found.
In the following example the class has two methods with the same name "Add" but with different input parameters (the first method has three parameters and the second method has two parameters).
Here the compiler checks the number of parameters passed and the type of parameter and make the decision of which method to call and it throw an error if no matching method is found.
In the following example the class has two methods with the same name "Add" but with different input parameters (the first method has three parameters and the second method has two parameters).
1. public class TestData
2. {
3. public int Add(int a, int b, int c)
4. {
5. return a + b + c;
6. }
7. public int Add(int a, int b)
8. {
9. return a + b;
10. }
11. }
12. class Program
13. {
14. static void Main(string[] args)
15. {
16. TestData dataClass = new TestData();
17. int add2 = dataClass.Add(45, 34, 67);
18. int add1 = dataClass.Add(23, 34);
19. }
20. }
Dynamic / Runtime Polymorphism
Dynamic / runtime polymorphism is also known as late binding.
Here, the method name and the method signature (number of parameters and
parameter type must be the same and may have a different implementation).
Method overriding is an example of dynamic polymorphism.
Method overriding can be done using inheritance. With method overriding it is possible for the base class and derived class to have the same method name and same something. The compiler would not be aware of the method available for overriding the functionality, so the compiler does not throw an error at compile time. The compiler will decide which method to call at runtime and if no method is found then it throws an error.
Method overriding can be done using inheritance. With method overriding it is possible for the base class and derived class to have the same method name and same something. The compiler would not be aware of the method available for overriding the functionality, so the compiler does not throw an error at compile time. The compiler will decide which method to call at runtime and if no method is found then it throws an error.
1. public class Drawing
2. {
3. public virtual double Area()
4. {
5. return 0;
6. }
7. }
8.
9. public class Circle : Drawing
10. {
11. public double Radius { get; set; }
12. public Circle()
13. {
14. Radius = 5;
15. }
16. public override double Area()
17. {
18. return (3.14) * Math.Pow(Radius, 2);
19. }
20. }
21.
22. public class Square : Drawing
23. {
24. public double Length { get; set; }
25. public Square()
26. {
27. Length = 6;
28. }
29. public override double Area()
30. {
31. return Math.Pow(Length, 2);
32. }
33. }
34.
35. public class Rectangle : Drawing
36. {
37. public double Height { get; set; }
38. public double Width { get; set; }
39. public Rectangle()
40. {
41. Height = 5.3;
42. Width = 3.4;
43. }
44. public override double Area()
45. {
46. return Height * Width;
47. }
48. }
49.
50. class Program
51. {
52. static void Main(string[] args)
53. {
54.
55. Drawing circle = new Circle();
56. Console.WriteLine("Area :" + circle.Area());
57.
58. Drawing square = new Square();
59. Console.WriteLine("Area :" + square.Area());
60.
61. Drawing rectangle = new Rectangle();
62. Console.WriteLine("Area :" + rectangle.Area());
63. }
64. }
The compiler requires an Area() method and it compiles successfully but the right version of the Area() method is not being determined at compile time but determined at runtime. Finally the overriding methods must have the same name and signature (number of parameters and type), as the virtual or abstract method defined in the base class method and that it is overriding in the derived class.
20. ASP.NET Application & PAGE Life Cycle
What is ASP.Net Page
Lifecycle?
When an ASP.Net page is called, it goes through a particular
lifecycle. This is done before the response is sent to the user. There are
series of steps which are followed for the processing of an ASP.Net page.
Let's look at the various stages of the lifecycle of an ASP.Net
web page.
Following are the different stages of an ASP.NET
page:
·
Page request - When ASP.NET gets a
page request, it decides whether to parse and compile the page, or there would
be a cached version of the page; accordingly the response is sent.
·
Starting of page life cycle -
At this stage, the Request and Response objects are set. If the request is an
old request or post back, the IsPostBack property of the page is set to true.
The UICulture property of the page is also set.
·
Page initialization -
At this stage, the controls on the page are assigned unique ID by setting the
UniqueID property and the themes are applied. For a new request, postback data
is loaded and the control properties are restored to the view-state values.
·
Page load - At this stage,
control properties are set using the view state and control state values.
·
Validation - Validate method of
the validation control is called and on its successful execution, the IsValid
property of the page is set to true.
·
Postback event handling -
If the request is a postback (old request), the related event handler is
invoked.
·
Page rendering - At this stage, view
state for the page and all controls are saved. The page calls the Render method
for each control and the output of rendering is written to the OutputStream
class of the Response property of page.
·
Unload - The rendered page
is sent to the client and page properties, such as Response and Request, are
unloaded and all cleanup done.
21.
ASP.NET Application Life Cycle
The application life cycle has the following stages:
·
User makes a request for accessing application resource, a page.
Browser sends this request to the web server.
·
A unified pipeline receives the first request and the following
events take place:
o An
object of the class ApplicationManager is created.
o An
object of the class HostingEnvironment is created to provide information
regarding the resources.
o Top
level items in the application are compiled.
·
Response objects are created. The application objects such as
HttpContext, HttpRequest and HttpResponse are created and initialized.
·
An instance of the HttpApplication object is created and assigned
to the request.
·
The request is processed by the HttpApplication class. Different
events are raised by this class for processing the request.
22. ASP.NET
MVC Application & PAGE Life Cycle
1. Routing
Asp.net Routing is the
first step in MVC request cycle. Basically it is a pattern matching system that
matches the request’s URL against the registered URL patterns in the Route
Table. When a matching pattern found in the Route Table, the Routing engine
forwards the request to the corresponding IRouteHandler for that request. The
default one calls the
MvcHandler
. The routing engine
returns a 404 HTTP status code against that request if the patterns is not
found in the Route Table.
When application
starts at first time, it registers one or more patterns to the Route Table to
tell the routing system what to do with any requests that match these patterns.
An application has only one Route Table and this is setup in the Global.asax
file of the application.
1. public static void RegisterRoutes(RouteCollection routes)
2. {
3. routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
4. routes.MapRoute( "Default", // Route name
5. "{controller}/{action}/{id}", // URL with parameters
6. new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
7. );
8. }
2.
Mvc Handler
The MvcHandler is
responsible for initiating the real processing inside ASP.NET MVC. MVC handler
implements IHttpHandler interface and further process the request by
using
ProcessRequest
method as shown
below:1. protected internal virtual void ProcessRequest(HttpContextBase httpContext)
2. {
3. SecurityUtil.ProcessInApplicationTrust(delegate {
4. IController controller;
5. IControllerFactory factory;
6. this.ProcessRequestInit(httpContext, out controller, out factory);
7. try
8. {
9. controller.Execute(this.RequestContext);
10. }
11. finally
12. {
13. factory.ReleaseController(controller);
14. }
15. });
16. }
3.
Controller
As shown in above
code, MvcHandler uses the IControllerFactory instance and tries to get a
IController instance. If successful, the Execute method is called. The
IControllerFactory could be the default controller factory or a custom factory
initialized at the
Application_Start
event, as shown
below:1. protected void Application_Start()
2. {
3. AreaRegistration.RegisterAllAreas();
4. RegisterRoutes(RouteTable.Routes);
5. ControllerBuilder.Current.SetControllerFactory(new CustomControllerFactory());
6. }
4.
Action Execution
Once the controller
has been instantiated, Controller's ActionInvoker determines which specific
action to invoke on the controller. Action to be execute is chosen based on
attributes
ActionNameSelectorAttribute
(by default
method which have the same name as the action is chosen) and ActionMethodSelectorAttribute
(If more than one
method found, the correct one is chosen with the help of this attribute).
5. View Result
The action method
receives user input, prepares the appropriate response data, and then executes
the result by returning a result type. The result type can be ViewResult,
RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult,
and EmptyResult.
6. View Engine
The first step in the
execution of the View Result involves the selection of the appropriate View
Engine to render the View Result. It is handled by
IViewEngine
interface of
the view engine. By default Asp.Net MVC uses WebForm
and Razor
view engines.
You can also register your own custom view engine to your Asp.Net MVC
application as shown below:1. protected void Application_Start()
2. {
3. //Remove All View Engine including Webform and Razor
4. ViewEngines.Engines.Clear();
5. //Register Your Custom View Engine
6. ViewEngines.Engines.Add(new CustomViewEngine());
7. //Other code is removed for clarity
8. }
7.
View
Action method may
returns a text string,a binary file or a Json formatted data. The most
important Action Result is the ViewResult, which renders and returns an HTML
page to the browser by using the current view engine.
23. Top MVC question ?
https://medium.com/dot-net-tutorial/top-50-asp-net-mvc-interview-questions-with-answers-1fd9b1638c61
24.
Abstract class
An
Abstract class is an incomplete class or special class we can't instantiate. We
can use an Abstract class as a Base Class. An Abstract method must be
implemented in the non-Abstract class using the override keyword. After
overriding the abstract method is in the non-Abstract class. We can derive this
class in another class and again we can override the same abstract method with
it.
Features:
- An
abstract class can inherit from a class and one or more interfaces.
- An
abstract class can implement code with non-Abstract methods.
- An
Abstract class can have modifiers for methods, properties etc.
- An
Abstract class can have constants and fields.
- An
abstract class can implement a property.
- An
abstract class can have constructors or destructors.
- An
abstract class cannot be inherited from by structures.
- An
abstract class cannot support multiple inheritance.
Example
1:
#region
//An abstract calss can inherit
from a class and one or more interfaces.
interface IVendorTransDetails
{
void getVendorID();
}
interface IClaimsTracker
{
void getSeqID();
}
class ClaimsMaster
{
string getDCNNO()
{
return "PC20100308A00005";
}
}
Example 2:
abstract class Abstract : ClaimsMaster, IClaimsTracker, IVendorTransDetails
{
//Here we should implement modifiers oterwise it throws complie-time error
public void getVendorID()
{
int s = new int();
s = 001;
Console.Write(s);
}
interface IVendorTransDetails
{
void getVendorID();
}
interface IClaimsTracker
{
void getSeqID();
}
class ClaimsMaster
{
string getDCNNO()
{
return "PC20100308A00005";
}
}
Example 2:
abstract class Abstract : ClaimsMaster, IClaimsTracker, IVendorTransDetails
{
//Here we should implement modifiers oterwise it throws complie-time error
public void getVendorID()
{
int s = new int();
s = 001;
Console.Write(s);
}
public void getSeqID()
{
int SeqID = new int();
SeqID = 001;
Console.Write(SeqID);
}
}
#endregion
{
int SeqID = new int();
SeqID = 001;
Console.Write(SeqID);
}
}
#endregion
25.
Virtual.
A virtual method can be redefined. The virtual keyword
designates a method that is overridden in derived classes. We can add derived
types without modifying the rest of the program. The runtime type of objects
thus determines behavior.
This program introduces 2 classes. Class A has a public
virtual method called Test. Class B, meanwhile, derives from class A and it
provides a public override method called Test as well.
Tip: The virtual modifier tells the compiler that when any
class derived from class A is used, an override method should be called.
Based on: .NET (2018)
C# program that introduces virtual method
using System;
class A
{
public virtual void Test()
{
Console.WriteLine("A.Test");
}
}
class B : A
{
public override void Test()
{
Console.WriteLine("B.Test");
}
}
class Program
{
static void Main()
{
// Compile-time type is A.
// Runtime type is A as well.
A ref1 = new A();
ref1.Test();
// Compile-time type is A.
// Runtime type is B.
A ref2 = new B();
ref2.Test();
}
}
Indus net
Interview Question:
1. Abstraction
2. Encapsulation
3. Interface
4. Polymorphism type
5. Virtual class
6. Overriding
7. Overloading
8. How to implement encapsulation in c#
9. Asp .Net life cycle
10. MVC life cycle
11. MVC definition
12. MVC section (true / false )
13. Html render partial and html partial
deferent.
14. Session handling in MVC
15. Filter types. Action filter work
process
16. What is Routing
17. Asp .Net viewstate
SQL
1. Difference between Varchar and
NVarchar
2. Delete duplicate row query
3. 2nd highest salary output
4. Group by
5. Having clause
6. Temp table and type table deferent
7. Cursor
8. Index
9. IIS server
10. $each function in javascript
11. Web garden
12. Worker process
13. Application poll
Answer:-
1.
Abstract
class
An Abstract class is an incomplete class or
special class we can't instantiate. We can use an Abstract class as a Base
Class. An Abstract method must be implemented in the non-Abstract class using
the override keyword. After overriding the abstract method is in the
non-Abstract class. We can derive this class in another class and again we can
override the same abstract method with it.
2.
Encapsulation
is implemented by using access specifies. An access specifies defines
the scope and visibility of a class member. C# supports the following access specifies
−
Public
Private
Protected
Internal
Protected
internal
3. What is Interface?
An interface
looks like a class, but has no implementation. The only thing it contains are
declarations of events,
Indexers,
methods and/or properties. The reason interfaces only provide declarations is
because they are inherited by
structs and
classes, that must provide an implementation for each interface member
declared.
4. Difference
between Html.Partial() and Html.RenderPartial() in ASP.NET MVC
Html.Partial()
|
Html.RenderPartial()
|
Html.Partial returns html string.
|
Html.RenderPartial returns void.
|
Html.Partial injects html string of the partial view into main
view.
|
Html.RenderPartial writes html in response stream.
|
Performance is slow.
|
Perform faster than HtmlPartial().
|
Html.Partial() need not to be inside the braces.
|
Html.RenderPartial must be inside braces @{ }.
|
5.
Types of
Filters
ASP.NET MVC framework
supports the following action filters −
·
Action Filters −
Action filters are used to implement logic that gets executed before and after
a controller action executes.
·
Authorization Filters −
Authorization filters are used to implement authentication and authorization
for controller actions.
·
Result Filters −
Result filters contain logic that is executed before and after a view result is
executed. For example, you might want to modify a view result right before the
view is rendered to the browser.
·
Exception Filters −
Exception filters are the last type of filter to run. You can use an exception
filter to handle errors raised by either your controller actions or controller
action results. You also can use exception filters to log errors.
6. Viewstate in asp net c#
View State is
the method to preserve the Value of the Page and Controls between round trips.
It is a Page-Level State Management technique.
View State is
turned on by default and normally serializes the data in every control on the
page regardless of whether it is actually used during a post-back.
7. What is the difference between SQL
server varchar and nvarchar data type?
VARCHAR Data type: -
- Non Unicode variable length character data type.
-Takes 1 byte per character.
-Used to store data which contains non unicode characters.
-Uses 1 byte per character + 2 extra bytes for storing offset.
-Can store maximum of 8000 non unicode characters.
NVARCHAR Data type:-
-Unicode variable length character data type.
-Takes 2 bytes per character.
-Used to store both unicode(like Japanese, Korean etc.) and non unicode characters.
-Uses 2 bytes per character + 2extra bytes for storing offset.
-Can store maximum of 4000 unicode characters/non unicode characters.
- Non Unicode variable length character data type.
-Takes 1 byte per character.
-Used to store data which contains non unicode characters.
-Uses 1 byte per character + 2 extra bytes for storing offset.
-Can store maximum of 8000 non unicode characters.
NVARCHAR Data type:-
-Unicode variable length character data type.
-Takes 2 bytes per character.
-Used to store both unicode(like Japanese, Korean etc.) and non unicode characters.
-Uses 2 bytes per character + 2extra bytes for storing offset.
-Can store maximum of 4000 unicode characters/non unicode characters.
8. Delete duplicate row query?
DELETE FROM Studemt_tbl WHERE
Id IN
(
SELECT MIN(Id) FROM Studemt_tbl
GROUP BY Name HAVING COUNT(Id)>1
)
9. 2nd highest salary output query?
SELECT MAX(Roll) as SndRoll From Studemt_tbl WHERE
Roll < ( SELECT Max(Roll) FROM Studemt_tbl);
10.
What is the Group by Clause?
The GROUP BY clause is a SQL command that is used
to group rows that have the same values.
The GROUP BY clause is used in the SELECT statement
.Optionally it is used in conjunction with aggregate functions to produce
summary reports from the database.
Example: SELECT `gender`,COUNT(`membership_number`) FROM `members` GROUP BY `gender`;
11. The HAVING Clause enables you to specify conditions
that filter which group results appear in the results.
SELECT column_name(s) FROM table_name WHERE condition GROUP
BY column_name(s) HAVING condition ORDER BY column_name(s);
SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID)
> 5;
12.
Local Temporary Tables
Local temporary tables are the tables stored
in tempdb. Local temporary tables are temporary tables that are available
only to the session that created them. These tables are automatically destroyed
at the termination of the procedure or session. They are specified with the
prefix #, for example #table_name and these temp tables can be created with the
same name in multiple windows. Local temporary table
name is stared with hash
("#"
) sign.
13.
Cursor:
A cursor is a pointer to this context area. PL/SQL controls the
context area through a cursor. A cursor holds the rows (one or more) returned
by a SQL statement. The set of rows the cursor holds is referred to as
the active set.
You can name a cursor so that it could be referred to in a
program to fetch and process the rows returned by the SQL statement, one at a
time. There are two types of cursors −
·
Implicit cursors
·
Explicit cursors
14. Index in SQL :
An index helps to speed up SELECT queries and WHERE clauses,
but it slows down data input, with the UPDATE and the INSERT statements.
Indexes can be created or dropped with no effect on the data.
·
Indexes should not be used on small tables.
·
Tables that have frequent, large batch updates or insert
operations.
·
Indexes should not be used on columns that contain a high number
of NULL values.
·
Columns that are frequently manipulated should not be indexed.
Types of indexes:
·
Clustered. Clustered indexes sort and store the data
rows in the table or view based on their key values. These
are the columns included in the index definition. ...
·
Nonclustered. Nonclustered indexes have a structure separate from the data
rows.
15. Internet Information Server
Internet Information Server (IIS) is one of the most popular
web servers from Microsoft that is used to host and provide Internet-based
services to ASP.NET and ASP Web applications. A web server is responsible for
providing a response to requests that come from users. When a request comes
from client to server IIS takes that request from users and process it and send
response back to users
16.
$.each($('.productDescription'), function
(index, value) {
console.log(index +
':' + $(value).text());
});
17.
Web garden is a
scenario in which a single machine has multiple asp.net worker processes
running simultaneously. A web garden is utilized on a multi-core web server. To
achieve more robust execution and processing of the C# ASP .NET web application
threads, each worker process within the application pool would execute on an
individual processor. It is created within Internet Information Services (IIS)
by creating an application pool, selecting the Performance tab, and under the
"Web Garden" section, setting the maximum number of worker processes
to a value greater than 1.
Advantages of Web Garden
- It
increases application availability
- Less
consumption of physical space with better capacity
- Optimum
utilization of processes running on multiple processors located in a single
server
- Finer
grained partitioning of Web servers help to control the administration of
web sites individually, though they reside on the same server
- With
the concept of Processor affinity (binding the application to processor
with the help of CPU masks), applications can be swapped out and restarted
on the fly.
18.
Worker
Process: Worker Process (w3wp.exe) runs the ASP.Net
application in IIS. This process is responsible for managing all the request
and response that are coming from the client system. All the ASP.Net
functionality runs under the scope of the worker process. When a request
comes to the server from a client worker process is responsible for generating
the request and response. In a single word, we can say worker process is the
heart of ASP.NET Web Application which runs on IIS.
Application Pool: Application pool is the container of the worker process. Application pools are used to separate sets of IIS worker processes that share the same configuration. Application pools enable a better security, reliability, and availability for any web application. The worker process serves as the process boundary that separates each application pool so that when one worker process or application is having an issue or recycles, other applications or worker processes are not affected. This makes sure that a particular web application doesn’t impact other web application as they are configured into different application pools.
Constant
Constant fields or local variables must be assigned a value
at the time of declaration and after that they cannot be modified. By default
constant are static, hence you cannot define a constant type as static.
Constants are declared
using a "const" keyword.
ReadOnly
A readonly field can be initialized either at the time of
declaration or with in the constructor of same class. Therefore, readonly
fields can be used for run-time constants.
Types of Filters in ASP.NET MVC and their
Sequence of Execution
There are five types of Filters in ASP.NET MVC 5:
There are five types of Filters in ASP.NET MVC 5:
- Authentication Filters:
Authentication filter runs before any other filter or action method. Authentication confirms that you are a valid or invalid user. Action filters implements the IAuthenticationFilter interface.
- Authorization Filters:
The AuthorizeAttribute and RequireHttpsAttribute are the examples of Authorization Filters. Authorization Filters are responsible for checking User Access; these implement the IAuthorizationFilterinterface in the framework. These filters used to implement authentication and authorization for controller actions. For example, the Authorize filter is an example of an Authorization filter.
- Action Filters:
Action Filter is an attribute that you can apply to a controller action or an entire controller. This filter will be called before and after the action starts executing and after the action has executed.
Action filters implement the IActionFilter interface that have two methods OnActionExecuting and OnActionExecuted. OnActionExecuting runs before the Action and gives an opportunity to cancel the Action call. These filters contain logic that is executed before and after a controller action executes, you can use an action filter, for instance, to modify the view data that a controller action returns.
- Result Filters:
The OutputCacheAttribute class is an example of Result Filters. These implement the IResultFilter interface which like the IActionFilter has OnResultExecuting and OnResultExecuted. These filters contains logic that is executed before and after a view result is executed. Like if you want to modify a view result right before the view is rendered to the browser.
- ExceptionFilters:
The HandleErrorAttribute class is an example of ExceptionFilters. These implement the IExceptionFilter interface and they execute if there are any unhandled exceptions thrown during the execution pipeline. These filters can be used as an exception filter to handle errors raised by
6. A
practical example:
7. 1.You
have an iframe that has a youtube player.
8. 2.You
request some videos to play from youtube data api (CORS, could be JSONP, XHR or
whatever).
9. 3.You
now pass a cross-domain message to the iframe to start playing any of the video
you requested in step #2.
10. From
Reference: http://stackoverflow.com/a/8186722
11. Also
from WikiPedia definition:
12. Cross-origin
resource sharing (CORS) is a mechanism that allows
many resources (e.g., fonts, JavaScript, etc.) on a web page to
be requested from another domain outside
the domain from which the resource originated.[1] In
particular, JavaScript's AJAX calls
can use the XMLHttpRequest mechanism. Such
"cross-domain" requests would otherwise be forbidden by web browsers,
per the same-origin security policy. CORS defines a way in which
the browser and the server can interact to determine whether or not to allow
the cross-origin request.[2] It
is more useful than only allowing same-origin requests, but it is more secure
than simply allowing all such cross-origin requests.
What is a
Callback?
Simply put: A callback is a function that is to be
executed after another function has finished executing — hence the
name ‘call back’.
Ready
Function in JQuery ?
When using another
JavaScript library, we may wish to call $.noConflict() to avoid namespace
difficulties. When this function is called, the $ shortcut is no longer
available, forcing us to write jQuery each time we would normally write $.
However, the handler passed to the .ready() method can take an argument, which
is passed the global jQuery object.
State Management in Asp.net MVC?
HTTP is a stateless protocol, i.e., each HTTP
request does not know about the previous request. If you are redirecting from
one page to another page, then you have to maintain or persist your data
so that you can access it further. To do this, there were many techniques
available in ASP.NET like ViewState, SessionState, ApplicationState etc.
ASP.NET MVC also provides state management
techniques that can help us to maintain the data when redirecting from one page
to other page or in the same page after reloading. There are several ways to do
this in ASP.NET MVC -
- Hidden Field
- Cookies
- Query String
- ViewData
- ViewBag
- TempData
Difference between normal application and mvc
application ?
ASP.NET MVC vs Web Forms
ASP.NET MVC
|
Web Forms
|
|
1
|
MVC focuses on
separation of concern, i.e., there is no any fixed code behind page for every
view. A view can be called from multiple action.
|
Web form based on
functions and page behind code, i.e., there is code behind page for each
view. You have to write code in that class related to this view only.
|
2
|
First request comes
to controller and action, then view gets called.
|
First request comes
to Page (View) then it will go to code behind page.
|
3
|
MVC provides HTML
Helpers to create form controls. This is optional. You can use simple HTML
controls also.
|
For everything in
webforms, you have a server control.
|
4
|
There is no ViewState for
state management in View.
|
Viewstate is used to maintain state of form in
view. This also makes page heavy.
|
5
|
Good for SEO
friendly urls. No need to map to existing physical files.
|
Earlier, this
feature was not available in Webforms but now it is available. Although it is
not that easy and it is optional.
|
6
|
We create partial
views for reusable views.
|
We create user
controls for reusable view or control.
|
7
|
It is very easy to
use jquery and JavaScripts. Using CSS is also easy
|
It is a little
difficult to use jquery and JavaScripts in web forms. It provides themes and
it is difficult to manage design of server controls.
|
8
|
Maintaining Id of
form controls are easy and you can fully control them when working with
Jquery.
|
It is difficult to
mange Id of server controls, you don't know adject id of server controls most
of the time. Specially working with user controls.
|
What Is Data
annotation?
Data validation is a key aspect for developing web application.
In Asp.net MVC, we can easily apply validation to web application by using Data
Annotation attribute classes to model class. Data Annotation attribute classes
are present in System.ComponentModel.DataAnnotations namespace and are
availlable to Asp.net projects like Asp.net web application & website,
Asp.net MVC, Web forms and also to Entity framework orm models.
Data Annotations help us to define the rules to the model
classes or properties for data validation and displaying suitable messages to
end users.
Data Annotation
Validator Attributes:
· DataType
·
Specify the datatype of a property
·
DisplayName
·
specify the display name for a property.
·
DisplayFormat
·
specify the display format for a property like different format
for Date proerty.
·
Required
·
Specify a property as required.
·
ReqularExpression
·
validate the value of a property by specified regular expression
pattern.
·
Range
·
validate the value of a property with in a specified range of
values.
·
StringLength
·
specify min and max length for a string property.
·
MaxLength
·
specify max length for a string property.
·
Bind
·
specify fields to include or exclude when adding parameter or
form values to model properties.
·
ScaffoldColumn
·
specify fields for hiding from editor forms.
About JsonResult format and its properties?
The JSON
format is an open standard format. The format of data looks very easy to
understand and the data objects consist of attribute-value pairs.
ContentEncoding: It helps to indicate the content encoding type, the
default encoding for JSON is UTF-8.
ContentType: It helps to indicate the content type. The default content type
for JSON is application/json; charset=utf-8.
Note: ContentType and ContentEncoding are not necessary to
mention when sending the data in JSON format as the HTTP headers are having a
responsibility to tell the recipient what kind of content they're dealing with.
Data: This indicates what the content data is, that means what you will
send in JSON format.
JsonRequestBehavior: This property has two options. Those are AllowGet and DenyGet.
The default option is DenyGet. When you send data in JSON format, using Get
Request, it's necessary to specify the property as AllowGet otherwise it shows
the error as “The request would be blocked since the JSON data is considered as
sensitive data information”.
MaxJsonLength: This helps to get or set the maximum JSON content length
that you will send. The default value for this is 2097152 characters, that is
equal to 4 MB of Unicode string data. You can even increase the size based if
needed, for that you will get an idea later in this article.
RecursionLimit: Indicates the constraining number of object levels to
process. The default value is 100. It means you can serialize the objects that
are nested to a depth of 100 objects referencing each other. In a general
scenario, the default limit 100 is obviously sufficient when you deal with a
JsonResult so there is no need to increase it even though you have the option
to increase the limit if required.
Filters run in the
following order:
There are the following types of filters that can be implemented to inject custom processing logic.
There are the following types of filters that can be implemented to inject custom processing logic.
- Authorization filter
- Action filter
- Result filter
- Exception filter
Create
custom view engine in MVC application
There are various third-party view engines available like Nhaml
(pronounced enamel), spark, Brail, nVelocity but the most famous one is Razor
used .cshtml and .vbhtml files
to recognize views to render as simple HTML.
You can create your own view engine and even use that with other
view engines in one application. To use your custom view engine, you have to
register your view engine in global.aspx file.
OLTP
(online transaction processing)
OLTP (online transaction processing) is a class of software
programs capable of supporting transaction-oriented
applications on the Internet.
Typically, OLTP systems are used for order entry, financial
transactions, customer relationship management (CRM) and retail
sales. Such systems have a large number of users who conduct short
transactions. Database queries are
usually simple, require sub-second response times and return relatively few
records.
What
is RDBMS?
RDBMS stands
for Relational Database Management System. RDBMS is the
basis for SQL, and for all modern database systems like MS SQL Server, IBM DB2,
Oracle, MySQL, and Microsoft Access.
A Relational database management system (RDBMS) is a
database management system (DBMS) that is based on the relational model as
introduced by E. F. Codd.
Properties of Relational Table?
Relational
tables have six properties: 1. Values are atomic. 2. Column values are of
the same kind. 3. Each row is unique. 4. The sequence of columns is
insignificant. 5. The sequence of rows is insignificant. 6. Each column must
have a unique name.
Difference between primary key and unique key in sql server?
Primary Key
- Primary
key cannot have a NULL value.
- Each
table can have only one primary key.
- By
default, Primary key is clustered index, and the data in database table is
physically organized in the sequence of clustered index.
- Primary
key can be related to another tables as a Foreign Key.
- We
can generate ID automatically with the help of Auto Increment field.
Primary key supports Auto Increment value.
- We
can define Primary key constraint on temporary table and table
variable.
- We
can't delete primary key value from the parent table which is used as a
foreign key in child table. To delete we first need to delete that primary
key value from the child table.
Unique Key
- Unique
Constraint may have a NULL value.
- Each
table can have more than one Unique Constraint.
- By
default, Unique key is a unique non-clustered index.
- Unique
Constraint can not be related with another table's as a Foreign Key.
Foreign Key
- Foreign
key is a field in the table that is Primary key in another table.
- Foreign
key can accept multiple null value.
- Foreign
key do not automatically create an index, clustered or non-clustered. You
can manually create an index on foreign key.
- We
can have more than one foreign key in a table.
- Foreign
keys do not automatically create an index, clustered or non-clustered. You
must manually create an index on foreign keys.
- There
are actual advantages to having a foreign key be supported with a
clustered index, but you get only one per table. What's the advantage? If
you are selecting the parent plus all child records, you want the child
records next to each other. This is easy to accomplish using a clustered
index.
- Having
a null foreign key is usually a bad idea instead of NULL referred to
as "orphan record".
- We
can’t define foreign key constraint on temporary table or table variable.
- We
can delete the foreign key value from the child table even though that
refers to the primary key of the parent table.