SQL :
1- How to retrive the deleted records?
2-How we can delete Duplicate records exists in a table, Please give query and the possible ways of query?
3-Write a query to Select top nth Highest salary from an employee table?
4-Write a query to Select top nth Highest salary from an employee table group by dept?
5-How we can swap the value 0-1 and 1-0 in single query statement?
6-Write q query to find all the employees whose salary is between 50000 to 100000 and name starts with 'S'.
7- Write a query to create a new table which consists of data and structure copied from the other table.
8- How do you find all employees and thier managers in same employee table?
9- Write an SQL query to fetch only odd rows from the table.
10-Write an SQL query to find the count of the total occurrences of a particular character – ‘a’ in th
ASP.NET Questions and answers:
1. Explain the life cycle of an ASP .NET page.?
Following are the events occur during ASP.NET Page Life Cycle:
1)Page_PreInit
2)Page_Init
3)Page_InitComplete
4)Page_PreLoad
5)Page_Load
6)Control Events
7)Page_LoadComplete
8)Page_PreRender
9)SaveViewState
10)Page_Render
11)Page_Unload
Among above events Page_Render is the only event which is raised by page. So we can't write code for this event.
2. how does the cookies work in asp.net?
we know Http is an state-less protocol which is required for interaction between client and server .
so there is an need to remember state of request raised by an web browser so that
web server can recognize you have already previously visited or not.
There are two types of state management techniques:
a) Client side state management
b) Server - side state management
Using cookies comes under client side state management .In HttpResponse we write
Cookie containing sessionId and other information within it.
when a browser made a request to the web server the same cookie is sent to the server where server recognize the session id and get other information stored to it previously.
3. What is Ispostback method in ASP.Net? Why do we use that??
Basically Post back is an action performed by a interactive Webpage. When it goes to the server side for a non-client Operation Server again posts it back to the client and hence the name.
Ex:
if(!IsPostBack)
will not allow the page to post back again n again bcoz it reduces the performance.
4. Can User Control be stored in library?.
I will say "NO"
there are 3 types of controls:
1) User Control
2) Custom Control
3) Web parts
you can reuse User control in the current project in which you have built it, but you can't move it to other project as unless you just copy paste the same file there and make the changes for that project ( which violets the concept of library).
but custom control can be shared between projects. and you can precompile them even as a dll, so this means you can use them in library of any type.
5. what is the difference between application state and caching?
Application Object and Cached Object both falls under Server side State Management.
Application object resides in InProc i.e. on the same server where we hosted our application.
Cache Object resides on server side/ DownStream/Client Side.
Application Object will be disposed once application will stop.
Cache Object can be disposed using Time based cache dependency.
Only one user can access Application Object at a time hence we have to lock it every time we modify it.
6. what is boxing and unboxing?
Boxing is what happens when a value-type object is assigned to a reference-type variable.
Unboxing is what happens when a reference-type variable is assigned to a value-type variable.
7. What are the uses of Reflection??
Reflection is a concept using which we can
1) Load assemblies dynamically
2) Invoke methods at runtime
3) Retrieving type information at runtime.
8. What is the use of AutoWireup in asp.net?
AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
In the case where AutoEventWireup attribute is set to false (by default) event handlers are automatically required for Page_Load or Page_Init. However when we set the value of the AutoEventWireup attribute to true the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.
9. what events will occur when a page is loaded?
Below are the events occurs during page load.
1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
10. Where is the View state Data stored?
ViewState data is stored in the hidden field. When the page is submitted to the server the data is sent to the server in the form of hidden fields for each control. If the viewstate of the control is enable true the value is retained on the post back to the client when the page is post backed.
11. What is the difference between custom web user control and a custom web server control?
Web User Control:
1) Easy to Create.
2) It Can be used inside the same Application.(To use it in other application we need to add it to that project.)
3) It Can take advantage of Caching Technique.
Web Server Control:
1) Bit tuff to create as compare to User Control.
2) Easy to use.
3) Can be added to ToolBox.
12. Where do the Cookie State and Session State information be stored?
Cookie Information will be stored in a txt file on client system under a
folder named Cookies. Search for it in your system you will find it.
Coming to Session State
As we know for every process some default space will be allocated by OS.
In case of InProc Session Info will be stored inside the process where our
application is running.
In case of StateServer Session Info will be stored using ASP.NET State Service.
In case of SQLServer Session info will be stored inside Database. Default DB
which will be created after running InstallSQLState Script is ASPState.
13. What is the difference between adding reference in solution Explorer and adding references by USING ?
Adding reference in solution explorer is used to add the DLL for that project for reference only. If you want to utilize that DLL methods/functions in our aspx.cs/.cs file etc you must write using that name class library name in file.
14. What are the different types of sessions in ASP.Net? Name them.?
Session Management can be achieved in two ways
1)InProc
2)OutProc
OutProc is again two types
1)State Server
2)SQL Server
InProc
Adv.:
1) Faster as session resides in the same process as the application
2) No need to serialize the data
DisAdv.:
1) Will degrade the performance of the application if large chunk of data is stored
2) On restart of IIS all the Session info will be lost
State Server
Adv.:
1) Faster then SQL Server session management
2) Safer then InProc. As IIS restart
won't effect the session data
DisAdv.:
1) Data need to be serialized
2) On restart of ASP.NET State Service session info will be lost
3)Slower as compared to InProc
SQL Server
Adv.:
1) Reliable and Durable
2) IIS and ASP.NET State Service
restart won't effect the session data
3) Good place for storing large chunk of data
DisAdv.:
1) Data need to be serialized
2) Slower as compare to InProc and State Server
3)Need to purchase Licensed
version of SQL Serve
15. How do you design a website with multilingual support in ASP.NET?
Multilingual website can be created using Globalization and Localization.
Using Globalization we change the Currency Date Numbers etc to Language Specific Format.
To change the string which is there in the label button etc to language specific string we use Localization.
In Localization we have to create different Resource files for different languages.
During this process we use some classes present in System.Resources System.Globalization System.Threading namespaces.
16. What is caching? What are different ways of caching in ASP.NET?
Caching is a technique of persisting the data in memory for immediate access to requesting program calls. This is considered as the best way to enhance the performance of the application.
Caching is of 3 types:
Output Caching - Caches the whole page.
Fragment Caching - Caches a part of the page
Data Caching - Caches the data
17. What is meant by 3-tier architecture.
We generally split our application into 3-Layers
1)Presentation Layer ( Where we keep all web forms Master Pages and User Controls).
2)Business Layer (Where we keep business logic). e.g Code related to manipulating data Custom Exception classes Custom Control classes Login related code if any etc. etc.
3)Data Access Layer (Where we keep code used to interact with DB). e.g. We can have the methods which are using SQL Helper (Application Block).
18. Explain the basic functionality of garbage collector?
Garbage Collector in .Net Framework is used for Automatic Memory Management i.e. it is collect all unused memory area and give to application. system.gc.collect() is a method for release the memory. But remember one think it is only an request i.e. we can't explicitly release the memory by using system.gc.collect().
19. What is the difference between machine.config and web.config?
machine.config is a system level configuration i.e it is applied on all application in o/s that the configuration is set where as in web.config it is applicable to only one application i.e each asp.net web application will contain at least on web.config file.
20. How can exception be handled with out the use of try catch?
using Exception Management application block
or
Page_error
Application_error objects
21. What is the difference between Response.Redirect and Server.Transfer.
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server.Server.Transfer does not update the clients url history list or current url.
Response.Redirect is used to redirect the user's browser to another page or site. This performs a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
22. Where the assembly is stored in asp.net?.
private are stored in application / bin directory and public are stored in GAC.
23. How we implement Web farm and Web Garden concept in ASP.NET?.
A web farm is a multi-server scenario. So we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt.
How they bear it is based on various models.
1. RoundRobin. (All servers share load equally)
2. NLB (economical)
3. HLB (expensive but can scale up to 8192 servers)
4. Hybrid (of 2 and 3).
5. CLB (Component load balancer).
A web garden is a multi-processor setup. i.e. a single server (not like the multi server above).
How to implement webfarms in .Net:
Go to web.config and
Here for mode you have 4 options.
a) Say mode inproc (non web farm but fast when you have very few customers).
b) Say mode StateServer (for webfarm)
c) Say mode SqlServer (for webfarm)
Whether to use option b or c depends on situation. StateServer is faster but SqlServer is more reliable and used for mission critical applications.
How to use webgardens in .Net:
Go to web.config and
Change the false to true. You have one more attribute that is related to webgarden in the same tag called cpuMask.
24. Is there any limit for query string? means what is the maximum size?..
Servers should be cautious about depending on URI lengths above 255 bytes because some older client or proxy implementations may not properly support these lengths.
Query string length depends on browser compatibility
IE supports up to 255
Firefox supports up to 4000
25. What is the exact purpose of http handlers?
ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have the same functionality as ISAPI extensions with a much simpler programming model
Ex
1.Default HttpHandler for all ASP.NET pages ->ASP.NET Page Handler (*.aspx)
2.Default HttpHandler for all ASP.NET service pages->ASP.NET Service Handler (*.asmx)
An HttpHandler can be either synchronous or asynchronous. A synchronous handler does not return until it finishes processing the HTTP request for which it is called. An asynchronous handler usually launches a process that can be lengthy and returns before that process finishes
After writing and compiling the code to implement an HttpHandler you must register the handler using your application's Web.config file.
MVC Interview Questions/Answers
Following are the events occur during ASP.NET Page Life Cycle:
1)Page_PreInit
2)Page_Init
3)Page_InitComplete
4)Page_PreLoad
5)Page_Load
6)Control Events
7)Page_LoadComplete
8)Page_PreRender
9)SaveViewState
10)Page_Render
11)Page_Unload
Among above events Page_Render is the only event which is raised by page. So we can't write code for this event.
2. how does the cookies work in asp.net?
we know Http is an state-less protocol which is required for interaction between client and server .
so there is an need to remember state of request raised by an web browser so that
web server can recognize you have already previously visited or not.
There are two types of state management techniques:
a) Client side state management
b) Server - side state management
Using cookies comes under client side state management .In HttpResponse we write
Cookie containing sessionId and other information within it.
when a browser made a request to the web server the same cookie is sent to the server where server recognize the session id and get other information stored to it previously.
3. What is Ispostback method in ASP.Net? Why do we use that??
Basically Post back is an action performed by a interactive Webpage. When it goes to the server side for a non-client Operation Server again posts it back to the client and hence the name.
Ex:
if(!IsPostBack)
will not allow the page to post back again n again bcoz it reduces the performance.
4. Can User Control be stored in library?.
I will say "NO"
there are 3 types of controls:
1) User Control
2) Custom Control
3) Web parts
you can reuse User control in the current project in which you have built it, but you can't move it to other project as unless you just copy paste the same file there and make the changes for that project ( which violets the concept of library).
but custom control can be shared between projects. and you can precompile them even as a dll, so this means you can use them in library of any type.
5. what is the difference between application state and caching?
Application Object and Cached Object both falls under Server side State Management.
Application object resides in InProc i.e. on the same server where we hosted our application.
Cache Object resides on server side/ DownStream/Client Side.
Application Object will be disposed once application will stop.
Cache Object can be disposed using Time based cache dependency.
Only one user can access Application Object at a time hence we have to lock it every time we modify it.
6. what is boxing and unboxing?
Boxing is what happens when a value-type object is assigned to a reference-type variable.
Unboxing is what happens when a reference-type variable is assigned to a value-type variable.
7. What are the uses of Reflection??
Reflection is a concept using which we can
1) Load assemblies dynamically
2) Invoke methods at runtime
3) Retrieving type information at runtime.
8. What is the use of AutoWireup in asp.net?
AutoEventWireup attribute is used to set whether the events needs to be automatically generated or not.
In the case where AutoEventWireup attribute is set to false (by default) event handlers are automatically required for Page_Load or Page_Init. However when we set the value of the AutoEventWireup attribute to true the ASP.NET runtime does not require events to specify event handlers like Page_Load or Page_Init.
9. what events will occur when a page is loaded?
Below are the events occurs during page load.
1) Page_PreInit
2) Page_Init
3) Page_InitComplete
4) Page_PreLoad
10. Where is the View state Data stored?
ViewState data is stored in the hidden field. When the page is submitted to the server the data is sent to the server in the form of hidden fields for each control. If the viewstate of the control is enable true the value is retained on the post back to the client when the page is post backed.
11. What is the difference between custom web user control and a custom web server control?
Web User Control:
1) Easy to Create.
2) It Can be used inside the same Application.(To use it in other application we need to add it to that project.)
3) It Can take advantage of Caching Technique.
Web Server Control:
1) Bit tuff to create as compare to User Control.
2) Easy to use.
3) Can be added to ToolBox.
12. Where do the Cookie State and Session State information be stored?
Cookie Information will be stored in a txt file on client system under a
folder named Cookies. Search for it in your system you will find it.
Coming to Session State
As we know for every process some default space will be allocated by OS.
In case of InProc Session Info will be stored inside the process where our
application is running.
In case of StateServer Session Info will be stored using ASP.NET State Service.
In case of SQLServer Session info will be stored inside Database. Default DB
which will be created after running InstallSQLState Script is ASPState.
13. What is the difference between adding reference in solution Explorer and adding references by USING ?
Adding reference in solution explorer is used to add the DLL for that project for reference only. If you want to utilize that DLL methods/functions in our aspx.cs/.cs file etc you must write using that name class library name in file.
14. What are the different types of sessions in ASP.Net? Name them.?
Session Management can be achieved in two ways
1)InProc
2)OutProc
OutProc is again two types
1)State Server
2)SQL Server
InProc
Adv.:
1) Faster as session resides in the same process as the application
2) No need to serialize the data
DisAdv.:
1) Will degrade the performance of the application if large chunk of data is stored
2) On restart of IIS all the Session info will be lost
State Server
Adv.:
1) Faster then SQL Server session management
2) Safer then InProc. As IIS restart
won't effect the session data
DisAdv.:
1) Data need to be serialized
2) On restart of ASP.NET State Service session info will be lost
3)Slower as compared to InProc
SQL Server
Adv.:
1) Reliable and Durable
2) IIS and ASP.NET State Service
restart won't effect the session data
3) Good place for storing large chunk of data
DisAdv.:
1) Data need to be serialized
2) Slower as compare to InProc and State Server
3)Need to purchase Licensed
version of SQL Serve
15. How do you design a website with multilingual support in ASP.NET?
Multilingual website can be created using Globalization and Localization.
Using Globalization we change the Currency Date Numbers etc to Language Specific Format.
To change the string which is there in the label button etc to language specific string we use Localization.
In Localization we have to create different Resource files for different languages.
During this process we use some classes present in System.Resources System.Globalization System.Threading namespaces.
16. What is caching? What are different ways of caching in ASP.NET?
Caching is a technique of persisting the data in memory for immediate access to requesting program calls. This is considered as the best way to enhance the performance of the application.
Caching is of 3 types:
Output Caching - Caches the whole page.
Fragment Caching - Caches a part of the page
Data Caching - Caches the data
17. What is meant by 3-tier architecture.
We generally split our application into 3-Layers
1)Presentation Layer ( Where we keep all web forms Master Pages and User Controls).
2)Business Layer (Where we keep business logic). e.g Code related to manipulating data Custom Exception classes Custom Control classes Login related code if any etc. etc.
3)Data Access Layer (Where we keep code used to interact with DB). e.g. We can have the methods which are using SQL Helper (Application Block).
18. Explain the basic functionality of garbage collector?
Garbage Collector in .Net Framework is used for Automatic Memory Management i.e. it is collect all unused memory area and give to application. system.gc.collect() is a method for release the memory. But remember one think it is only an request i.e. we can't explicitly release the memory by using system.gc.collect().
19. What is the difference between machine.config and web.config?
machine.config is a system level configuration i.e it is applied on all application in o/s that the configuration is set where as in web.config it is applicable to only one application i.e each asp.net web application will contain at least on web.config file.
20. How can exception be handled with out the use of try catch?
using Exception Management application block
or
Page_error
Application_error objects
21. What is the difference between Response.Redirect and Server.Transfer.
Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client's browser. This provides a faster response with a little less overhead on the server.Server.Transfer does not update the clients url history list or current url.
Response.Redirect is used to redirect the user's browser to another page or site. This performs a trip back to the client where the client's browser is redirected to the new page. The user's browser history list is updated to reflect the new address.
22. Where the assembly is stored in asp.net?.
private are stored in application / bin directory and public are stored in GAC.
23. How we implement Web farm and Web Garden concept in ASP.NET?.
A web farm is a multi-server scenario. So we may have a server in each state of US. If the load on one server is in excess then the other servers step in to bear the brunt.
How they bear it is based on various models.
1. RoundRobin. (All servers share load equally)
2. NLB (economical)
3. HLB (expensive but can scale up to 8192 servers)
4. Hybrid (of 2 and 3).
5. CLB (Component load balancer).
A web garden is a multi-processor setup. i.e. a single server (not like the multi server above).
How to implement webfarms in .Net:
Go to web.config and
Here for mode you have 4 options.
a) Say mode inproc (non web farm but fast when you have very few customers).
b) Say mode StateServer (for webfarm)
c) Say mode SqlServer (for webfarm)
Whether to use option b or c depends on situation. StateServer is faster but SqlServer is more reliable and used for mission critical applications.
How to use webgardens in .Net:
Go to web.config and
Change the false to true. You have one more attribute that is related to webgarden in the same tag called cpuMask.
24. Is there any limit for query string? means what is the maximum size?..
Servers should be cautious about depending on URI lengths above 255 bytes because some older client or proxy implementations may not properly support these lengths.
Query string length depends on browser compatibility
IE supports up to 255
Firefox supports up to 4000
25. What is the exact purpose of http handlers?
ASP.NET maps HTTP requests to HttpHandlers. Each HttpHandler enables processing of individual HTTP URLs or groups of URL extensions within an application. HttpHandlers have the same functionality as ISAPI extensions with a much simpler programming model
Ex
1.Default HttpHandler for all ASP.NET pages ->ASP.NET Page Handler (*.aspx)
2.Default HttpHandler for all ASP.NET service pages->ASP.NET Service Handler (*.asmx)
An HttpHandler can be either synchronous or asynchronous. A synchronous handler does not return until it finishes processing the HTTP request for which it is called. An asynchronous handler usually launches a process that can be lengthy and returns before that process finishes
After writing and compiling the code to implement an HttpHandler you must register the handler using your application's Web.config file.
MVC Interview Questions/Answers
What are the 3 main components of an ASP.NET MVC application?
1. M - Model
2. V - View
3. C - Controller
In which assembly is the MVC framework defined?
System.Web.Mvc
Is it possible to combine ASP.NET webforms and ASP.MVC and develop a single web application?
Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a single web application.
What does Model, View and Controller represent in an MVC application?
Model: Model represents the application data domain. In short the applications business logic is contained with in the model.
View: Views represent the user interface, with which the end users interact. In short the all the user interface logic is contained with in the UI.
Controller: Controller is the component that responds to user actions. Based on the user actions, the respective controller, work with the model, and selects a view to render that displays the user interface. The user input logic is contained with in the controller.
What is the greatest advantage of using asp.net mvc over asp.net webforms?
It is difficult to unit test UI with webforms, where views in mvc can be very easily unit tested.
Which approach provides better support for test driven development - ASP.NET MVC or ASP.NET Webforms?
ASP.NET MVC
What are the advantages of ASP.NET MVC?
1. Extensive support for TDD. With asp.net MVC, views can also be very easily unit tested.
2. Complex applications can be easily managed
3. Seperation of concerns. Different aspects of the application can be divided into Model, View and Controller.
4. ASP.NET MVC views are light weight, as they do not use viewstate.
Is it possible to unit test an MVC application without running the controllers in an ASP.NET process?
Yes, all the features in an asp.net MVC application are interface based and hence mocking is much easier. So, we don't have to run the controllers in an ASP.NET process for unit testing.
Is it possible to share a view across multiple controllers?
Yes, put the view into the shared folder. This will automatically make the view available across multiple controllers.
What is the role of a controller in an MVC application?
The controller responds to user interactions, with the application, by selecting the action method to execute and alse selecting the view to render.
Where are the routing rules defined in an asp.net MVC application?
In Application_Start event in Global.asax
Name a few different return types of a controller action method?
The following are just a few return types of a controller action method. In general an action method can return an instance of a any class that derives from ActionResult class.
1. ViewResult
2. JavaScriptResult
3. RedirectResult
4. ContentResult
5. JsonResult
What is the significance of NonActionAttribute?
In general, all public methods of a controller class are treated as action methods. If you want prevent this default behavior, just decorate the public method with NonActionAttribute.
What is the significance of ASP.NET routing?
ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to controller action methods. ASP.NET Routing makes use of route table. Route table is created when your web application first starts. The route table is present in the Global.asax file.
What are the 3 segments of the default route, that is present in an ASP.NET MVC application?
1st Segment - Controller Name
2nd Segment - Action Method Name
3rd Segment - Parameter that is passed to the action method
Example: _http:// sitename . com/Customer/Details/5
Controller Name = Customer
Action Method Name = Details
Parameter Id = 5
ASP.NET MVC application, makes use of settings at 2 places for routing to work correctly. What are these 2 places?
1. Web.Config File : ASP.NET routing has to be enabled here.
2. Global.asax File : The Route table is created in the application Start event handler, of the Global.asax file.
What is the advantage of using ASP.NET routing?
In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.
An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.
What are the 3 things that are needed to specify a route?
1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.
2. Handler - The handler can be a physical file such as an .aspx file or a controller class.
3. Name for the Route - Name is optional.
Is the following route definition a valid route definition?
{controller}{action}/{id}
No, the above definition is not a valid route definition, because there is no literal value or delimiter between the placeholders. Therefore, routing cannot determine where to separate the value for the controller placeholder from the value for the action placeholder.
What is the use of the following default route?
{resource}.axd/{*pathInfo}
This route definition, prevent requests for the Web resource files such as WebResource.axd or ScriptResource.axd from being passed to a controller.
What is the difference between adding routes, to a webforms application and to an mvc application?
To add routes to a webforms application, we use MapPageRoute() method of the RouteCollection class, where as to add routes to an MVC application we use MapRoute() method.
How do you handle variable number of segments in a route definition?
Use a route with a catch-all parameter. An example is shown below. * is referred to as catch-all parameter.
controller/{action}/{*parametervalues}
What are the 2 ways of adding constraints to a route?
1. Use regular expressions
2. Use an object that implements IRouteConstraint interface
Give 2 examples for scenarios when routing is not applied?
1. A Physical File is Found that Matches the URL Pattern - This default behavior can be overriden by setting the RouteExistingFiles property of the RouteCollection object to true.
2. Routing Is Explicitly Disabled for a URL Pattern - Use the RouteCollection.Ignore() method to prevent routing from handling certain requests.
What is the use of action filters in an MVC application?
Action Filters allow us to add pre-action and post-action behavior to controller action methods.
If I have multiple filters implemented, what is the order in which these filters get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
What are the different types of filters, in an asp.net mvc application?
1. Authorization filters
2. Action filters
3. Result filters
4. Exception filters
Give an example for Authorization filters in an asp.net mvc application?
1. RequireHttpsAttribute
2. AuthorizeAttribute
Which filter executes first in an asp.net mvc application?
Authorization filter
What are the levels at which filters can be applied in an asp.net mvc application?
1. Action Method
2. Controller
3. Application
[b]Is it possible to create a custom filter?[/b]
Yes
What filters are executed in the end?
Exception Filters
Is it possible to cancel filter execution?
Yes
What type of filter does OutputCacheAttribute class represents?
Result Filter
What are the 2 popular asp.net mvc view engines?
1. Razor
2. .aspx
What symbol would you use to denote, the start of a code block in razor views?
@
What symbol would you use to denote, the start of a code block in aspx views?
<%= %>
In razor syntax, what is the escape sequence character for @ symbol?
The escape sequence character for @ symbol, is another @ symbol
When using razor views, do you have to take any special steps to protect your asp.net mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded to protect from cross site scripting (XSS) attacks.
When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of asp.net master pages. What is asp.net master pages equivalent, when using razor views?
To have a consistent look and feel when using razor views, we can make use of layout pages. Layout pages, reside in the shared folder, and are named as _Layout.cshtml
What are sections?
Layout pages, can define sections, which can then be overriden by specific views making use of the layout. Defining and overriding sections is optional.
What are the file extensions for razor views?
1. .cshtml - If the programming lanugaue is C#
2. .vbhtml - If the programming lanugaue is VB
How do you specify comments using razor syntax?
Razor syntax makes use of @* to indicate the begining of a comment and *@ to indicate the end. An example is shown below.
@* This is a Comment *@
1. M - Model
2. V - View
3. C - Controller
In which assembly is the MVC framework defined?
System.Web.Mvc
Is it possible to combine ASP.NET webforms and ASP.MVC and develop a single web application?
Yes, it is possible to combine ASP.NET webforms and ASP.MVC and develop a single web application.
What does Model, View and Controller represent in an MVC application?
Model: Model represents the application data domain. In short the applications business logic is contained with in the model.
View: Views represent the user interface, with which the end users interact. In short the all the user interface logic is contained with in the UI.
Controller: Controller is the component that responds to user actions. Based on the user actions, the respective controller, work with the model, and selects a view to render that displays the user interface. The user input logic is contained with in the controller.
What is the greatest advantage of using asp.net mvc over asp.net webforms?
It is difficult to unit test UI with webforms, where views in mvc can be very easily unit tested.
Which approach provides better support for test driven development - ASP.NET MVC or ASP.NET Webforms?
ASP.NET MVC
What are the advantages of ASP.NET MVC?
1. Extensive support for TDD. With asp.net MVC, views can also be very easily unit tested.
2. Complex applications can be easily managed
3. Seperation of concerns. Different aspects of the application can be divided into Model, View and Controller.
4. ASP.NET MVC views are light weight, as they do not use viewstate.
Is it possible to unit test an MVC application without running the controllers in an ASP.NET process?
Yes, all the features in an asp.net MVC application are interface based and hence mocking is much easier. So, we don't have to run the controllers in an ASP.NET process for unit testing.
Is it possible to share a view across multiple controllers?
Yes, put the view into the shared folder. This will automatically make the view available across multiple controllers.
What is the role of a controller in an MVC application?
The controller responds to user interactions, with the application, by selecting the action method to execute and alse selecting the view to render.
Where are the routing rules defined in an asp.net MVC application?
In Application_Start event in Global.asax
Name a few different return types of a controller action method?
The following are just a few return types of a controller action method. In general an action method can return an instance of a any class that derives from ActionResult class.
1. ViewResult
2. JavaScriptResult
3. RedirectResult
4. ContentResult
5. JsonResult
What is the significance of NonActionAttribute?
In general, all public methods of a controller class are treated as action methods. If you want prevent this default behavior, just decorate the public method with NonActionAttribute.
What is the significance of ASP.NET routing?
ASP.NET MVC uses ASP.NET routing, to map incoming browser requests to controller action methods. ASP.NET Routing makes use of route table. Route table is created when your web application first starts. The route table is present in the Global.asax file.
What are the 3 segments of the default route, that is present in an ASP.NET MVC application?
1st Segment - Controller Name
2nd Segment - Action Method Name
3rd Segment - Parameter that is passed to the action method
Example: _http:// sitename . com/Customer/Details/5
Controller Name = Customer
Action Method Name = Details
Parameter Id = 5
ASP.NET MVC application, makes use of settings at 2 places for routing to work correctly. What are these 2 places?
1. Web.Config File : ASP.NET routing has to be enabled here.
2. Global.asax File : The Route table is created in the application Start event handler, of the Global.asax file.
What is the advantage of using ASP.NET routing?
In an ASP.NET web application that does not make use of routing, an incoming browser request should map to a physical file. If the file does not exist, we get page not found error.
An ASP.NET web application that does make use of routing, makes use of URLs that do not have to map to specific files in a Web site. Because the URL does not have to map to a file, you can use URLs that are descriptive of the user's action and therefore are more easily understood by users.
What are the 3 things that are needed to specify a route?
1. URL Pattern - You can include placeholders in a URL pattern so that variable data can be passed to the request handler without requiring a query string.
2. Handler - The handler can be a physical file such as an .aspx file or a controller class.
3. Name for the Route - Name is optional.
Is the following route definition a valid route definition?
{controller}{action}/{id}
No, the above definition is not a valid route definition, because there is no literal value or delimiter between the placeholders. Therefore, routing cannot determine where to separate the value for the controller placeholder from the value for the action placeholder.
What is the use of the following default route?
{resource}.axd/{*pathInfo}
This route definition, prevent requests for the Web resource files such as WebResource.axd or ScriptResource.axd from being passed to a controller.
What is the difference between adding routes, to a webforms application and to an mvc application?
To add routes to a webforms application, we use MapPageRoute() method of the RouteCollection class, where as to add routes to an MVC application we use MapRoute() method.
How do you handle variable number of segments in a route definition?
Use a route with a catch-all parameter. An example is shown below. * is referred to as catch-all parameter.
controller/{action}/{*parametervalues}
What are the 2 ways of adding constraints to a route?
1. Use regular expressions
2. Use an object that implements IRouteConstraint interface
Give 2 examples for scenarios when routing is not applied?
1. A Physical File is Found that Matches the URL Pattern - This default behavior can be overriden by setting the RouteExistingFiles property of the RouteCollection object to true.
2. Routing Is Explicitly Disabled for a URL Pattern - Use the RouteCollection.Ignore() method to prevent routing from handling certain requests.
What is the use of action filters in an MVC application?
Action Filters allow us to add pre-action and post-action behavior to controller action methods.
If I have multiple filters implemented, what is the order in which these filters get executed?
1. Authorization filters
2. Action filters
3. Response filters
4. Exception filters
What are the different types of filters, in an asp.net mvc application?
1. Authorization filters
2. Action filters
3. Result filters
4. Exception filters
Give an example for Authorization filters in an asp.net mvc application?
1. RequireHttpsAttribute
2. AuthorizeAttribute
Which filter executes first in an asp.net mvc application?
Authorization filter
What are the levels at which filters can be applied in an asp.net mvc application?
1. Action Method
2. Controller
3. Application
[b]Is it possible to create a custom filter?[/b]
Yes
What filters are executed in the end?
Exception Filters
Is it possible to cancel filter execution?
Yes
What type of filter does OutputCacheAttribute class represents?
Result Filter
What are the 2 popular asp.net mvc view engines?
1. Razor
2. .aspx
What symbol would you use to denote, the start of a code block in razor views?
@
What symbol would you use to denote, the start of a code block in aspx views?
<%= %>
In razor syntax, what is the escape sequence character for @ symbol?
The escape sequence character for @ symbol, is another @ symbol
When using razor views, do you have to take any special steps to protect your asp.net mvc application from cross site scripting (XSS) attacks?
No, by default content emitted using a @ block is automatically HTML encoded to protect from cross site scripting (XSS) attacks.
When using aspx view engine, to have a consistent look and feel, across all pages of the application, we can make use of asp.net master pages. What is asp.net master pages equivalent, when using razor views?
To have a consistent look and feel when using razor views, we can make use of layout pages. Layout pages, reside in the shared folder, and are named as _Layout.cshtml
What are sections?
Layout pages, can define sections, which can then be overriden by specific views making use of the layout. Defining and overriding sections is optional.
What are the file extensions for razor views?
1. .cshtml - If the programming lanugaue is C#
2. .vbhtml - If the programming lanugaue is VB
How do you specify comments using razor syntax?
Razor syntax makes use of @* to indicate the begining of a comment and *@ to indicate the end. An example is shown below.
@* This is a Comment *@
.NET basics | Key words | |
IL code | Partially compiled | |
JIT(just in time) | IL code to machine language | |
Why is ithalf compiled ? | So that at run time we can detect the machine configuration , operating system give out optimized machine compiled code. | |
CLR | Heart of the engine , GC , compilation , CAS(Code access security) , CV ( Code verification) | |
CTS | Common data type for different .net languages so that integration is seamless | |
CLS | Specification of the IL code | |
CAS | It helps assign the .NET code permission of what they are capable of doing. | |
What has happed for CAS .NET 4.0 ? | ||
How does the .NET code compile ? | write the code (c#,vb.net,c++.net)-- compiles to a IL code -- CLR gives it to JIT -- JIT compiles to the machine specific language | |
Managed code | x` | |
Assembly | Its a unit deployment ( EXE , DLL) | |
DLL and EXE | EXE - Self starting , DLL - You have to link | |
Manifest | it describes more about the assembly ( Meta data):-Versioning, References , dependent objects , Security , Scope | |
how do you do versioning | Assemblyinfo.cs / right click properties -- assembly information | |
What are strongly typed and weakly typed references ? | They help you to identify the publisher. Strong typed means we identify the DLL with a public key token while weak references are just simple references and identified only by class names | |
What is DLL Hell ? | versioning done here | |
what is ref and out ? | ||
Strong names | They ensure that the class name is unique to avoid confusion | |
Delay signgin | This is meant to protect DLL identity from your internal team developers , public key is give to the developer by extracting using SN.EXE -p , when you ready to go for production you will onject the private key in the DLL SN.EXE -R | |
sn.exe | ||
Value and Reference types | Values types int , double , bool etc , Reference types objects and strings. Value types are allocated on stack and reference types are allocated on heap. Value types are stored on different memory locations while reference types point to the same memory location | |
Stack , heap | They are memory types .Stack has value types , heap has reference types | |
boxing , unboxing | Box - Convert from value to reference , unboxing - reference type to value | |
Does unboxing and boxing bring down performance ? | yes they do bring down performance because data has to jump between heap and stack memory types. | |
How can we avoid Boxing and unboxing ? | You can not avoid it just minimize it | |
Garbage collector | Managed Unused objects will be cleaned by this mechanism. As a best practice you do not write any clean up code for managed unused objects. | |
How does the GC run | Its run in background | |
Does garbage collector clean unmanaged code ? | No | |
Do I need to write clean up code for managed objects ? | No, GC is smart to figure out unused objects and clean them up | |
So what do I do for unmanaged ? | You need to write the cleanup in destructor | |
What kind of problems do we have with destructors from GC perspective ? | lot of objects created in gen1 | |
What are gen0 ,1 and 2? | Age of the objects.Gen 0 has newly created objects , gen 1 has objects which are bit older , while gen 2 has objects which is more older than gen 1.This is for GC optimization , garbage collector checks Gen 0 frequently rather than Gen 1 and Gen 2. | |
Finalize a.k.a destructor | It’s a desctructor for cleaning up unmanaged objects.Decreases performance because of objects move more to Generation 1. The time GC sees a destructor in a class it moves them to Gen 1 | |
how to ensure that lot of objects are not created in Gen 1 with class having destructor ? | Implement Idisposable -- Expose a Dispose function -- Call GC.SuppressFinalize | |
What is Dispose function ? | Its method exposed for clean up for client,Idisposable , Dispose , GC.SuppressFinalize | |
Finalize and Dispose | Finalize is a destructor and dispose is function which is implemented via Idisposable.Finalize is nondeterministic since we dont call it. It is up to the GC to call it. However dispose gives more control to the developer to perform cleanup. Since we can call it explicitly. | |
can we force garbage collector | Yes , GC.Collect | |
What are namespaces ? | They help us to logically group classes. | |
OOP | ||
Why do we need object oriented programming ? | 1.No thinking in terms of real world 2. Re usability 3. Extensibility 4 Simplicity and maintainability | |
Important principles | APIE (OOPs ( Encapsulation , inheritance , Polymorphism and Abstraction)) | |
How is the re-usability problem solved in OOPs ? | Its solved by using classes and creating objects wherever necessary | |
What is a class and what is object | Class -> Blue print , template , Objects -> Bring life in Class , they make them live | Create a simple windows screen , which has supplier name , supplier code , supplier date , button calculate payment date , supplier date + 1 month |
Encapsulation | Hide the complexity and make your object simple for external world. | |
How do we implement encapsulation | Encapsulation is implemented by using access modifiers | |
Can namespace span across DLL | yes , namespace are logical grouping of classes they can span | |
Abstraction | Show only what is necessary and its more a thought process and abstraction is implemented by encapsulation | |
Abstraction and Abstract classes | Abstraction is OOPs concept and Abstract classes is half defined classes | |
difference between Abstraction and Encapsulation | Abstraction complement Encapsulation , Encapsulation implements abstraction | |
Private , public , protected etc | Private - Only with in Class , Public - Seen everywhere , Protected - With in same class and inherited classes , Internal - Within same class and same project and Protected internal is combination of protected + internal i.e. with in same class , inherited class and same project file. | |
What are constructor and desctructor ? | Constructor(same name as class name with no return type) - initialization purpose , while destructor(~) is for cleaning purpose. | |
Inheritance parent child which constructor fires first | Parent Constructor fires first and then child. | |
What is multiple interfaces are implemented | It will qualify with interface name | |
How to prevent inheriting futher | use the sealed keyword | |
What is Static classes ? | Static object has only instance of the object created through out your application. | |
How to prevent object creation | Create the constructor as private | |
Where do we use the same ? | In Singleton pattern | |
Inheritance(:) | Depicts parent child relationship between classes | |
Polymprphism | objects will act different in differently under different situation | |
Method overloading | You can have same method name with different number / types of parameters and depending on different parameters and types the appropriate functions will be invoked. | |
What are the different ways of overloading | types , order , ref m out … do it | |
What is virtual and override keyword ? | Virtual keyword gives permission to its child classes to override the function / method. The child classes will then use the override keyword to override the same. | |
Whats the difference between overloading and overriding ? | Overloading we have same method / function names with different signatures ( input types) while overriding is a child parent concept where we override functionalities of the parent class. | |
Dynamic polymorphism | Method overriding and Virtual. You point your parent class object to child class objects to fire the necessary implementation on runtime. Even interfaces can be used to implement dynamic polymorphism | |
Static Ploymorphism | Method Overloading , we call same method with different input parameters | |
What is a interface | Its looks like a class but has no implementation. It has only empty definition of methods , functions, events , indexer. | |
What is the use of interface ? | to Establish a standard contract/standardization , to decouple classes, dynamic polymorphism( runtime bhevior) ,version , multiple inheritance | |
Point to be remembered for interfaces | Interface keyword is used to define interfaces. Interface can not have field variables. Interfaces can not have implemented functions and methods. All methods in a interface in child class needs to be implemented. Interface can be used to implement run time polymorphism. You can implement multiple interfaces. All interface methods are public | |
can we define public , private acess modifiers in interface ? | No , by default everything is public. | |
Do child classes need to implement all the methods of a interface ? | Yes | |
Can we create a object of interface or abstract class | No | |
Abstract and virtual | Abstract no implementation and virtual has implementation | |
Multiple constructor with parameters | ||
what is a abstract class ? | Half defined parent class / base class and child classes provide concrete implementation, like a generalization and specialization | |
What are abstract method and non-abstract method ? | Abstract method will not have any implementation while non-abstract method will have implementation they are normal .NET methods | |
Point to be remembered for Abstract classes | An abstract class cannot be a sealed class. An abstract method cannot be private. You can have protected and internal if you want to. The access modifier of the abstract method should be same in both the abstract class and its derived class. If you declare an abstract method as protected, it should be protected in its derived class. Otherwise, the compiler will raise an error. An abstract method cannot have the modifier virtual. Because an abstract method is implicitly virtual. An abstract member cannot be static. | |
Abstract classes and interfaces | Interface is a contract / standardization while abstract class is a half defined class for increasing reusability. Interface is forced implementation while abstract class is reusability via inheritance. | |
Can we have static methods in Abstract class ? | Yes | |
I have a interface IMyInterface which is implemented by class1 and class2 , I want to add some more functions and methods to the interface , what should I do ? | Create a new interface with additional methods or inherits from the interface and create a interface with methods and apply them. This ensure that the current contracts do not get disrupted. | |
Multiple code level inheritance | ||
versioning | ||
operator overloading | Operator overloading is a concept of polymorphism where you can redefine operators like + , - , * etc with additional functionalities. For instance we can redefine the + functionalities to add obejcts like obj1 + obj2. | |
Delegates | It’s a abstract strong typed pointer to a function | |
create and invoke a delegate | Declare , Create , point and invoke. | |
Use of delegate | Delegate refers via pointers so in case new methods are added or methods name changed we do not need to change at lot of places , dynamic calling of methods on run time. Its also strongly typed. Second - asynch calling and call back of methods | |
Delegate and interfaces | Delegate is at method level while interfaces are at class and object level. | |
Multicast delegate(+= , -=) | It helps them to point to multiple functions and execute them sequentially. | |
Use of Multicast delegate | For broadcasting to multiple classes | |
What is Unicast ? | When one delegate point to one function its called as unicast. | |
Events | Events encapsulates(hides) delegates. They are useful for broadcasting , publisher and subscriber | |
Difference between delegates and events | Events use delegates internally. Delegates are pointer to function while events encapsulates ( hides) delegate function. In event clients can only subscribe while in delegates the client can subscribe as well as call all the functions of the delegates. | |
Asynchronous delegates | Begininvoke and endinvoke , calls the methods of delegates asynch , for parallel execution. | |
covariance and contravariance(.net 4.0) | This helps to point delegates in a very generic fashion | |
Shadowing | It replaces the complete element of the parent class. Like method becomes a variable | |
Shadowing and overriding | in shadowing the complete elements is replaced and in overriding you only replace the implementation while the type remains same. | |
Shadowing practice | Should avoid Shadowing as far as possible. | |
Property indexer | ||
1.1 collection differences | ||
Difference between Array and Arraylist | Array - Fixed , ArrayList - resizable , Array has performance improvement as no boxing and unboxing takes place while in array list it does , Arraylist can not store multiple data types while array has fixed data types | |
What is a generic list | Strongly typed list and improves performance by avoiding boxing and unboxing | |
Generic confined the type | public class cls<T> where T : String | |
Hashtable | Stores the value as hashed key , good for comparison , but bad in terms inserting values | |
Stacks and Queues | First in first out and last in first out | |
Are there any performance problems with normal .NET collection ? | yes boxing unboxing happens | |
Regex and validation | Regex is nothing pattern matching and then validating the data using the pattern | |
GAC | To share the assembly across multiple application in the same computer (C:\WINDOWS\assembly) | |
how do we register in GAC ? | Give strong name to DLL by click on the signing tab -- second you use thr GACUTIL -I to register the assembly in GAC | |
If you have different versions ? | Use Bindingredirect , Oldversion and newversion | |
satellite assembly | It’s a compiled DLL which has images , text files any resource files. In other words no can tamper with your images , text files , icons etc. | |
Delay signing | ||
Generics | Its to increase re-usability by separating logic and data type and its strong typed. | |
What are generic collections / Where have you used generics | Generic collections enable simple .NET collections to be generic enabled. So a normal List can be attached with any data type and we can avoid casting | |
Does generic improve performance | Yes , type casting is avoided | |
Threading | Threading is used to do parallel execution. | |
How do we use threading | Create the thread object , pass the method name using thread start and call the start function. | |
can we set thread priority | Thread Priority | |
threading can we stop and suspend | yes by using thread.start , suspend , stop | |
Background and foreground thread | ||
read-only and constant | ||
What is reflection ? | BY using System.reflection you can read meta data like properties , methods and also if needed you can invoked the methods and functions dynamically. | |
In what scenarios we would use reflection ? | technological tools like VS IDE , code reviews tools like Fxcop , unit testing NUNIT etc | |
hod o you do reflection | Import system.reflection , get the type of t he object using gettype and then you can browser through function and proprieties , to invoke use the invokemember | |
What is Serialization ? | Helps to store in memory object in file and deserialization means read the value from file and bring it in memory back. | |
ASP.NET and Webservices | ||
Objects in ASP.NET | request , response , context , session and application | |
Autoeventwireup | ||
Autoeventwireup | When the request is send to the server from a UI element like button , drop down etc the postback happens | |
IIS , PORTS and Website | ||
Application pool concept | ||
HttpHandler and httpModules | They are means by which you can inject pre/post-processing logic before the request reaches the page /gif/html | |
HttpHandler | HttpHandler is extension based processor. | |
.ASHX | Its nothing but Httphandler below , they helps us to display data which does need asp.net pages and thus they improve performance | |
HttpModule | HttpModule is a event based processor | |
Create a HttpModule | Create a class ,implement IhttpModule, attach events with your methods and register the class in web.config in httpmodule tag | |
Create a HttpHandler | Create a class implement IhttpHandler , define implementation for processrequest, register the class in web.config with file extensions in httphandler tag | |
ASP.NET application and page life cycle | environment created(request , response , context) - http module event ( begin request etc) - httphandlers ( page extensions) - page event (S/ILVER)-http module (end request) | |
What logic should be written in what events ? | init (add controls dynamically), load(write logic),validate(fire your validation),event(ui element events),pre-render(changes before HTML is generated) , render ( changes before HTML is sent to the browser) and Unload ( clean up) | |
What is the difference between render and pre-render ? | Pre-render event happens just before the HTML is generated while render event happens when the HTML is sent to the browser. | |
What is a ISAPI ? | ||
UI controls ( buttong , text box , drop down .. | ||
why do you need Session ? | HTTP is a stateless protocol and in order to remember states during postback we need session variables | |
how do we do Session management in ASP.NET ? | inproc (session object), outproc ( sql server and state server) | |
how do we implement Inproc session management in Asp.Net ? | by using session object of ASP.NET | |
Are session variables are local to a user ? | Yes | |
What is a viewstate ? | Its meant for session management and it uses hidden fields internally.Viewstate is a way to manage session using client browser , it uses hidden fields internally. | |
What is difference between viewstate and session variables ? | Viewstate value is accessed only in the current page while session variables can be accessed in different pages also. | |
What are the problems with viewstate | Security | |
What is web farm ? | Many times our current load demand increases. We can then create Web farm which has two or more servers to meet the load.On the front end there is load balancer who routes the load to the appropriate server on load basis. | |
What is a loadbalancer? | Loadbalancer helps to decide which server the request should be routed. There are many load balancers one of the is Windows NLB ( network load balancer) in windows server | |
What is web garden ? | You would like your IIS processes to run on different processors of the machine rather than loading only one processor. | |
How to implement web garden ? | In the process model tag ( web.config or machine.config) provide the CPU mask value in decimal equivalent of the binary. | |
Why do we need a outproc session ? | Outproc sessions are needed in web farm environment | |
How can we do out proc session | step 1 - create session tables using ASPNET_REGSQL , Step 2 : Set <sessionState mode="SQLServer" with connection-string point to the database where session tables where created. | |
What are server side session management and client side management ? | ||
Whats the life of session ? | Session time out or when the user closes the browser | |
state server | aware used for outproc session | |
How can we cache a ASP.NET page ? | By using the <%@ OutputCache Duration="20" Location="Client" VaryByParam="*" %> | |
What are the various ways by which you can cache your page ? | Param , Headers , Custom and UserControl. | |
How can we cache the whole page and sections of the page should be dynamic ? | By using ASP:Substitution ( post cache substitution) | |
Cache whole page | outputcache directive at page level | |
Whole page dynamic and sections of the page is cached | Outputcache directive at usercontrol level. | |
Whole page cached and sections of the page is dynamic | Substitution control. | |
How can we cache as per location | location = server , downstream , client | |
What is a Application and Cache object ? | They help to create global objects in Asp.Net application. | |
What is the difference between cache and application object ? | In cache we can define dependency while application objects we can not define dependency. | |
What is cache dependency ? | you can define 3 kins of dependency file , time and key. If these dependencies change then the cache object becomes null. | |
If cache dependencies changes does it reload the depedency ? | No Cachdepedency does not have automation , we need to write t he code of refresh and reload. | |
Absolute and sliding | ||
what is scavenging ? | ||
Postback | When your user control sends data to the server postback event happens | |
Autopostback | When you want to send data to server as soon as the value changes in the control. It’s a simple property which we need set on the control. | |
Ispostback | It’s a page property to check if the postback has happened or not | |
Configuration setting in web.config | in the appsettings | |
Server.transfer and response.redirect | response.redirect has a double trip while server transfer transfers control from the server itself. Using response.redirect you can redirect cross domains while server transfer you can redirect only between pages of the same domain. | Create a simple project with page1.aspx and page2.aspx , create a simple buttong and in the button click redirect from page1.aspx to page2.aspx in the button click event |
Authentication | Who the user is? | |
Authorization | What rights does the user has ? | |
How do you know the user logged in to ASP.NET system ? | using principal and identity objects which belongs to System.Security namespace. | |
What are different ways of authentication and authorization | Windows , Forms and Passport | |
What is Forms Authentication ? | It’s a ticket based authentication . Tickets are passed via URL or stored in cookie file at the user browser. | |
What does actually a ticket mean ? | Ticket is a identification saying that you are a valid user. By using ticket you do not need to send userid and password again and again. Userid and password are sent first time , ticket is generated and later this ticket identifies your security role and rights. | |
What is windows authentication ? | In this the users are validated from windows local users and groups. | |
What is passport authentication ? | In this the users are validated from Microsoft sites like hotmail , devhood , MSN etc , ticket is generated and that ticket can be used to do authentication . Autho in your web application. | |
how can we implement Windows authentication ? | Create users in yours windows user group -- in web.config file define <authentication mode="Windows"/> -- <deny users="?"/> Deny anonymous users - map page name and roles. | |
How can we do Forms Authentication ? | Authentication mode = forms in web.config file ,FormsAuthentication.RedirectFromLoginPage/Authenticate | |
what if cookies are disabled in forms authentication ? | Its passed via browser URL. | |
Single sign on | Single sign on is a concept where you login to one website and it automatically authorizes and authenticates other websites. | |
How can we implement Single sign on ? | Create a machine validation key using (using RNGCryptoServiceProvider) - define the same machine validation key in to the web.config file for all websites which will be coming in the single sign on -- use forms authentications | |
aspnet membership and roles | It helps to expedite your development for authentication and authorization by giving ready made user and roles tables , user interfaces and API to connect to those tables. | |
how does ASP.Net membership roles work ?. | run aspnet_regsql -- do web.config configuration ( connection string , providers and roles) -- call the API from your ASP.NET behind code (Membership.CreateUser,Roles.CreateRole and Membership.ValidateUser) | |
Debugging and Tracing in ASP.NET | Tracing is a way to monitor the execution of your ASP.NET application. You can record exception details and program flow in a way that doesn't affect the program's output. | dev |
how can we do tracing in ASP.NET pages | Trace=true | dev |
whats the problem with trace=true | our debugging is shown to the end users , so we need to use tracelisteners | dev |
How can we configure tracelisteners and source ? | In web.config file define your source and listeners , in your code create the trace object and start sending messages(trace.write) | dev |
What is the namespace ? | It logically groups classes together | |
Ajax | Ajax is a technology by which you can do asynhcrounous processing and only the necessary values are posted rather than posting the whole page. Performance and great user experience. | |
What is updatpanel | Updatepanel is a component which ensures that your server objects become Ajax enabled.It logical groups them so that only that data is posted. | |
What is Script manager proxy ? | In Ajax we can have only one scropt manager. But there are condition like master pages where we would need two script manager | |
Enablepartial rendering | This enables asynchronous processing | |
How can we consume webservices in Ajax ? | In Script manager proxy give asp:servicereference and give ASMX path and use javascript to call the objects | |
What is Jquery ? | Jquery is javascript library to make your javascript development simpler. | |
Difference between datagrid , datalist and repeater | Datagrid displays everything as table , datalist has tables but gives flexibility like number of columns to displayed , while repeates is highly customizable, performance goes first repeater , then list and finally grid | |
Gridview and datagrid | Gridview is the successor of datagrid,Automatic handling of sorting, paging, updates, and deletes,Additional column types and design-time column operations, rich design capabilities | |
Paging in datagrid | ||
SQL Server | ||
Database and Tables | ||
SQL | ||
self/equi joins | ||
Referentrial integrity | ||
Normalization | It’s a database design technique to avoid repetitive data. | |
Normalization | 3 normal form , 1st normal form Break is Smallest unit , 2nd normal form any repetitive data should be moved to a separate table and foreign key , 3rd normal form Any non key field should not depend on other non key fields of the table | |
De-normalization | Its combining multiple table data in one table thus avoiding joins for performance imporvement ex - reporting applications | |
When should we use normalization and denorm | Normalization ( integrity , avoid redundant) and denorm ( faster retrieval , reporting etc) | |
Indexes | Indexes helps to make your search faster by using balance tree( B tree) concept | |
Balance tree | It’s a tree structure with leaf nodes having actual data , non leaf node and root node. So rather than browsing through records sequentially it zero's on range of records , this making your search faster | |
Clustered indexes | The leaf node points to actual data | |
Non-Clustered indexes | Leaf node points to a pointer and that pointer points to actual data | |
When will use a clustered index and not clustered index ? | You will choose fields with unique values as clustered indexes while fields which participate in search criteria you will select them as non-clustered indexes. | |
Self join | ||
inner join | ||
left join | ||
right join | ||
Cartesian | ||
case statements | ||
Select all rows from both tables | SELECT * FROM Customer INNER JOIN CustomerPaid ON Customer.Id = CustomerPaid.Id union SELECT * FROM Customer left JOIN CustomerPaid ON Customer.Id = CustomerPaid.Id union SELECT * FROM Customer right JOIN CustomerPaid ON Customer.Id = CustomerPaid.Id | |
in group by if we put a column which is not in group what will happen | Query will no fire | |
cross join / Cartesian | ||
Stored procedures | Stored procedures are SQL Server objects which have one or many SQL statements | |
What is advantage of SP over inline SQL | They are precompiled and thus increases performance ( parsing , plan and then execution) | |
What are triggers ? | Triggers are logic which you want to execute insert , delete and update operation on a table | |
What are types of triggers ? | After trigger ( fires after the operation )and instead of trigger ( before the operation). Operation means insert , update delete | |
What are inserted and deleted ? | ||
Functions | It returns a scalar value and is called from stored procedure | declare @count1 int set @count1= dbo.getfunctioncount() print(@count1) |
Difference between function and stored procedure | Function reduce redundant code in SP.Function - You can not change data while in stored procedures you can , can return only one value while SP returns multiple values, functions can be called inside a SP but not the viceversa | |
How to handle errors in Stored procedures | using Raiserror function , give message severity and state | |
Paramters in Stored procedure | input , output , return( only one) | |
profiler | It’s a simple listener tool which tracks what kind of SQL statements are fired on your SQL server and using it you can do debugging and improve performance depending on the trace file | |
optimzation | Create indexes ( balance tree), SQL Plan ( Table scan or Index scan) , SQL profiler and Data tuning advisor for getting suggestion of indexes | |
sql plan | Describes how your SQL statements will execute. | |
sql server locking | set isolation level read committed etc etc in stored procedure | |
SQl injection | It is a Form of attack on a database-driven Web site in which the attacker executes unauthorized SQL commands by taking advantage of insecure code on a system. | |
How can you avoid SQL injection | use stored procedures and avoid on the fly SQL concatenation. | |
SSIS | SSIS helps us to do ETL ( Extraction - Transformation and Loading). We need to create a Business intelligence project define source , transformation and destination and run the DTS package. | |
SSRS | ||
SSAS | ||
Difference between delete and truncate ? | ||
ADO.NET | ||
What are ADO.NET components ? | Connection , Command , Dataset , dataadapter , datareader(2C and 3D) | |
Whats the difference between Dataset and datareader ? | Dataset(back and forth) - works disconnectly , CRUD , reader works connecteldy | |
In what scenarios we will use a dataset and datareader ? | Dataset :- When you want to take group of records , modify/browse in offline mode( move back and forth) and then send the whole changes online. Datareader :- You have huge number of records and you want browse in the forward only direction | |
How do you connect to ADO.NET | connection , Command , ExecuteNonQuery/ExecuteQuery , use it and close it | |
how do you load a dataset | connection , Command , Dataadapter , load dataset by Fill method , use it and close it | |
Dataview | Helps to search, sort filter dataset | |
Command object methods | Executereader , executenonquery and executescalar | |
how can we use stored procedure in ADO.Net | ObjCommand.Commandtype = CommandType.Storedprocedure , give the stored procedure name | |
What is connection.close | To ensure the SQL Server resources are released | |
How do you write and read using XML using ADO.Net | readXML , WriteXML function of dataset object | |
Problems of Locking | Dirty Reads,Unrepeatable reads,Phantom reads and Lost updates | |
optimistic and pessimistic | Pessimistic means locks are acquired when the record is fetched until the updation and optimistic means locking is acquired when the data is updated | |
how can we do optimistic locking in ADO.Net ? | dataset and dataadapter by default supports optimistic locking , timestamp,checking old values and new values | |
Pessimistic locking | Read committed( reads data which is committed) , Read uncommitted ( reads data which is yet not committed), repetable read ( No updates allowed)and Serializable (Exclusive lock no updates , insert and selects). | |
Scenarios of pessimistic and optimistic | Transactional screens / data entry screen where large number of users,critical batch processes done at the end of the day or year( closing of accounts). | |
What is a transaction ? | When you have group of statements . Process doing insert update and delete , you would want either all of them pass or either all of them fail. | |
how can we implement trans | call begintransaction in connection object , committransaction or rollback, in stored procedure begin tran tr1 and commit tr1 | |
Connection pooling | Reuse the connection object rather than reusing from scratch.In connection string specify pooling=true | |
dataset is collection of tables with relationship and recordset has only tables | ||
How do you pass parameters t stored procedures | Parameter collection of command object | |
how can you automatically fill command object | Command builder. | |
Datarelation | ||
nerge | ||
Reporting | ||
Where do you get Crystal reports ? | It’s free available in VS | |
How did you create report using crystal reports | used RPT file -- Define my data sources -- Finally uses the reportviewer to display the RPT file on the UI. | |
how to provide inputs to crystal report | By parameter field | |
Remoting , Webservices and WCF | ||
What is Appdomain ? | Appdomains make logical boundary / isolation inside a process. Process -- Appdomains(task and application). | |
What's the advantage of Appdomain ? | If one Appdomain crashes the other Appdomain or the whole process is not closed / terminated. | |
What is the use of remoting ? | It helps to make remote method calls to objects which are residing in different appdomain. These Appdomain can be located in a different geographical location or different networks. | |
How do you create a remoting object ? | Create a interface -- Implement the object by creating MarshalbyRef -- Host your server object using Remoting"RegisterWellKnownServiceType" -- Create the client to call the service"Activator.GetObject". | |
Problems with remoting | Client and server can be only in .NET language , complicated, Faster than other remoting technologies, pick and choose Channel and formatter ( customization) | |
Comparison of DCOM and remoting | ||
remoting objects life time | ||
what is a webservice ? | Webservice is a technology by which you can expose your business functionality on HTTP using SOAP XML format. | |
How can we do webservice security | specify windows , passport , forms and pass credentials through the client proxy object | |
UDDI and DISCO | Helps to search and discover your webserbvice from the UDDI directory | |
What is WSDL ? | It’s a meta data which shows what are the methods , properties , datatypes exposed by a service | |
What is SOAP ? | It’s a XML protocol which is defined how your service and client communicate. | |
What is difference between Webservice and Remoting | Webservice(Cross language , only Http) , Remoting ( only .NET platform , Any protocol) | |
What is Service Oriented Archotecture ? | SOA is nothing but desigining your system in self contained services which communicate via standard messages thus making your services loosely coupled. Services -- Self contained , Orchestrate , Industry Standard messages , Reliable , Aynshcrounous message , Cross plat form describe and discover | |
Why WCF ? | It was to satisfy SOA principles of WS-* specification. | |
What is WCF ? | WCF = Webservices + remoting + COM plus + MSMQ | |
What is Address binding Contract ? | Address - where is it hosted , Binding - how is the protocol , Contract - what is the interfcae | |
What is Service contract , Operation contract and Data contract ? | Service contract - Service name , Operation contract - Your methods and functions , data contract - Custom data type , data member - property and functions of your data contract | |
namespace of WCF | System.ServiceModel | |
what's the difference between WCF and Webservices ? | Webservices = WCF - ( remoting( multiple protocols) + COM plus ( transactions) + MSMQ(queueing)) | |
What are the different hosting mechanisms of WCf services ? | IIS , Self hosting or WAS server | |
how do host in IIS ? | By suing the SVC file we can host our service on IIS | |
How do you do self hosting ? | Create object of Service host , provide Address ( Uri) , Binding ( Wshttpbinding) , Contract ( Interface) and open the host. | |
When should we go for Self hosting and when to go for IIS | Http go for IIS ( we getready made features like always running , process recycling,security,ssl etc), For other protocols go for self hosting | |
What are the important bindings/ | BasicHttp ( Like webservice plain text) , WsHttp ( Like basic with encryption) , TcpBinding ( To use TCP protocol for services ) , NetNamesPipe ( With in the same machine ) , MSMQ ( WCF integration with Queuing mechanism) | |
BasichttpBinding and WshttpBinding | basic is plain text while Wshtpp is encrypted | |
How to secure basichtppbinding | use SSL on webservices | |
Ho can we do debugging and tracing in WCF | In Web.config <system.diagnostics> specify WCF trace source objects like System.ServiceModel , message logging etc. , then use the Svtraceviewer tool to see the mesagges | |
How can we do transaction in WCF ? | 1 . Operation contract define TransactionFlow , 2. In Web.config file make your Binding as transaction flow as true 3. In client side call the services in one transaction scope with rollback and committ. | |
WCF Security | Transport , message and transport + message | |
WCF Transport | SSL , Specify in config file https in address tage , Specify security mode and install SSL in your WCF services | |
WCF overloading is it allowed | [ServiceContract] interface ICalculator { [OperationContract(Name="AddIntegers")] int Add(int a,int b) [OperationContract(Name="AddDouble")] double Add(double a,double b) } | |
Dynamic polymorphism | ||
WCF Duplex | ||
WCF message | ||
WCF Instancing | Per call , persesion and single instance | |
WCF concurrency | Single , Multiple , Rentrant | |
WCF REST | Helps to expose your WCF service via simple HTTP get and post | |
WCF integration | ||
LINQ and EF 4.0 | ||
What is LINQ | It’s a OR mapper technology ,2 important use 1 - BO , DAL and Mapping , 2 - General Queries which can fired on any data store. | |
What is a Entity class | It’s a Business object which has mapping with the data store. | |
What is data context | It’s the data connection layer to load the entity object with data | |
How do we declare 1 to many and 1 to 1 relation | Entity set for 1 to many and entity ref for 1 to 1 | |
LINQ to SQL | ||
Optimization using data load options | ||
CRUD example using LINQ | insertonsubit , deleteonsubmit , submitchanges | |
Call Stored procedures using LINQ | Using the function attribute | |
LINQ locking | ||
PLINQ | PLINQ executes two linq queries parallely | |
LINQ transactions | By using the transaction object of data context class | |
DBML | Database markup language | |
WPF and Silverlight | ||
GDI , GDI + and Directx | ||
Simple WPF application | WPF is for creating windows application , the user interfaces can be represented using XAML and it uses directx internally. | |
Rendering in WPF application | ||
Architecture of WPF | ||
What is silverlight ? | It’s a plugin which runs inside the browser. It can run on cross platform and cross browser. | |
Architecture of Silverlight | ||
Animation fundamentals in Silverlight | ||
What are different way of silverligjt layoutin.. | Stack panel ( one above another ),Canvas ( we specify left and top), Grid ( If you want layouting using table structure , rows and columns) | |
What are the different ways of binding the silverlight UI with .Net classes and objects ? | One way ( UI to BO), two way( UI <-> BO) and one time( BO to UI). | |
In what scenarios you will use what ? | One time binding - reports , Transaction screens two way , Pure input screen one way. | |
How can we connect froom Silverlight to SQL Server | By using WCF services. | |
Why not directly ? | Because silverlight is a plugin which is a downsized version .NET framework and it does not have system.data | |
Consume WCF service in Silverlight | WCF service should have client access policy and cross domain , from silverlight you need to call the data asynchrounously | |
Database operations using Silverlight | You can not call System.data directly from silverlight , so you need to call the WCF service and WCF service will do the necessary data operations | |
Prism | ||
MVVM | ||
WWF | ||
WWF architecture | ||
Composite and leaf activities | ||
Sequential and State machine work flow | ||
Simple example of WWF | ||
State machine work flow | ||
Design patterns | ||
Which design pattern have yu used ? | So pick your best pattern corelate it with your project and speak about it. Share global fdata | |
Design patterns | Design patterns are tried and tested solutions for design problems in our project. | |
What are the categories of Design patterns | Creational , Structural and Bheviorial | |
Factory pattern© | Centralizes creation of object in a class and passing back a interface reference to the client. Main use is decoupling( UI - BO - DAL).(Creates an instance of several derived classes ) | |
Abstract Factory Pattern | Abstract Factory groups Factory patterns. | |
Builder Pattern | ||
Prototype Pattern | ||
Where is prototype used ? | Audit trail , differences of objects , cancel and revert | |
Singleton Pattern | Helps to create one instance of the object. | |
How did you implement singleton pattern ? | Create a class with private constructor and define your object as static and expose it | |
We can achieve the same by cache and application | Its technology specifc and not a generalized solution | |
we can achieve the same by using static object | ||
Adapter Pattern | ||
Bridge Pattern | ||
Composite Pattern | ||
Decorator Pattern | ||
Facade Patetrn | ||
Flyweight Pattern | ||
Proxy Pattern | ||
Mediator Pattern | ||
Memento Pattern | ||
Interpreter Pattern | ||
Iterator Pattern | ||
COR Pattern | ||
Command Pattren | ||
State Pattern | ||
Strategy Pattern | ||
Observer Pattern | ||
Template Pattern | ||
Visitor Pattern | ||
DIIOCConcept Pattern | DI helps to inject depedent objects in to a class. DI injection can be implemented by Unity app block / Windsor castle | |
What is MVC,MVP and MVVM | These are GUI architectural pattern with only one intention of seprating the UI Logic , state and synchronization in to a separate class. | |
How is MVP | Hit come to UI first , from there he calls presenter clas , presenter call the model and present then send updates via a interface to the UI. UI --> I --> P - M | |
Model view controlle | Sepearetes Action , View and Data by using controller class. We have template MVC template which helps to automate the same. In odld asp.net we will httphandler which was tedious | |
MVP and MVC | First hit to the UI , First hit to the controller/MVP presenter takes care of logic , controller takes care of logic as well as statmanagement | |
When to use these patterns | If you have complicated UI code , MVC is mostly used for ASP.NET , MVVM is used for Silvetrlight and WPF becaiuse of rich command objects, MVP is not used currently because of less automation | |
UML | UML is a modelling language which helps us to document and design our software application. | |
Use Case Diagrams | Its helps us to document "What" of the system from user point of view. | |
What does use case have normally ? | Use cases are task having scenarios and Actor executing those scenarios | |
How did you document your requirement ? | Step 1 :- We identified the task which where nothing but our use cases , Step 2 :- For every use case we wrote down main scenario / alternate scenario and actors responsible | |
What are primary actors and secondary actors ? | Primary actors are the users who are the active participants and they initiate the use case, while secondary actors are those who only passively participate in the use case. | |
In which format did you gather your uses cases | Company Template in word document | |
How did you show relationship n uses cases | By Extend and include | |
How did you translate your requirement to design ? | We has already gathered the requirement using use cases and also relationships where between them using the include and extend, we use these use cases and identified nouns ( classes) and verbs ( they became our methods and functions) , relation ship between classes where identified by extend and include of use cases. Later for complex scenario we use Sequence diagram / Collobaration. We also had a over all architecture diagram which depicted hardware , components and logical grouping by using Component , Deployment and package. | |
Class Digrams | Class diagrams shows the static structure of project. They help us visualize the classes and relationships between them | |
How do you denote a class diagram in UML ? | Its denoted with square divided in to 3 section , top section has class name , middle section has properties and last section has operation / function / methods | |
How to demote public , private and protected in class diagram | (+) Public , (-)Private , (#) protected , internal | |
How do we define relationships in UML | by multiplicty (1-*) | |
What is composition and aggregation | Composition - life time of dependent objects are same , Aggregation :- Life time of dependent objects are not same and they can exist without each other. Composition is shown by filled diamond while aggregation is shown by empty diamond. | |
How can denote inheritance ? | Empty traingle arrow key. | |
How can we denote abstract classes and interfaces | {} - Abstract classes , <<>> - Interfaces | |
Object Diagrams | ||
Sequence Digrams | Object diagrams over a period of time. | |
how did you draw a sequence diagram ? | The objects in rectangle on the top side -- message by arrows and object life time vertical rectangles. | |
How do you show synchronous and asynch messages | Synch by dark arrow and asynch by thin arrow key | |
Recursive message | By small rectangle in a big rectangle | |
Conditcion | Inside Square bracket | |
Message branching | By two rectangles with condition and branching arrows from the same. | |
Collaboration Diagrams | It shows the same information as sequence diagram but the emphsais is more on messages than life time of the objects | |
Activity Diagram | Activity diagrams depicts complex flow of a system | |
Parallel processing , partionting and conditions | Shows by dark bar , Swimlanes for partitioning , Diamond is for conditions | |
State chart Diagrams | ||
Component Diagrams | ||
Deployment Diagrams | ||
Stereo Types Diagrams | ||
Package Diagram | ||
UML Project Flow | ||
Functionpoints | ||
Introduction | ||
EI Fundamentals | ||
EO Fundamentals | ||
EQ Fundamentals | ||
EIF Fundamentals | ||
ILF Fundamentals | ||
GSC Fundamentals | ||
Productivity Factor | ||
How did you reconcile | ||
How did you accommodate SDLC | ||
RUP | ||
What is Agile | Agile is a principle which means accept changes | |
How did you do Agile | Used SCRUM | |
What are the principles in Agile | Accept changes , Interaction with customer , people , working code | |
What is Agile SCRUM ? | Scrum is a methodology to implement agile | |
How does SCRUM process work | Customer Prepare Product back log -- priortizes them -- development team breaks them in to sprint -- every srpint has daily stand up meet( Today , yesterday,problems) -- Every week retrospective -- After sprint give chance of changing | |
When Agile and Waterfall ? | Water fall - requirement is fixed , Agile -- If requirements will change or evolve.( Time to market) | |
How did you code review? | Mostly automation and the process | |
Role of your current project(SDlC) | I was involved in all phases of SDLC cycle.Requirement( use cases , activity) - Design(Class , ER diagrams , Sequence / Collboaration) -coding / unit testing (NUNIT)- SIT - UAT - go live(junior ( coding) helped out ,poc( proof of concept) , pm / archotect) - end to end. | |
simplicity your projects | The applicaton was a integrator between indian chemical companies and EICA to provide certifications for Indian chemical companies as per EICA standards | It’s a internal ATM management system in ASP.NET which has various functionalities creating Contracts , Customer report , hand bills , Scheduling etc. |
Can you explain the architecture of your current project ? | It was a tiered architecture , UI / BO and DAL. With UI in ASPX pages , BO in normal .NET classes and data access layer helps to fire SQL queries on SQL Server. We had used singleton pattern and factory patterns in the project. | |
What software process did you follow for your project ? | We followed normal SDLC model. In requirement we wrote the use cases , design we created classes and DB diagrams , finally we coded and unitested and went live. | |
How did you test your project ? | ||
How did you do requirement for your project ? | ||
technical Design | ||
Acceptance | ||
How did you do unit testing in .NET ? | ||
Summary | ||
Speak abt yourself | ||
OOPs | ||
.net basic | ||
asp.net | ||
Why Gap ? | ||
Differences ( .NET , ASP.NET and SQL Server) | ||
HLD and LLD | I do understand HLD but most of the times we have created a overall index of LLD and then expanded in to details. The use of HLD is mostly to verify before investing in LLD that are we in the right direction , to take approval from stake holders. HLD has 5 section Overall all architecture diagram ( Deployment , Component diagram , package diagram) Overall Road map ( 3 tier , MVC , MVP MVVM) technology Unit testing Load test startergy POC :- Proof of concept LLD Overall detail architecture diagram Class diagrams , Object diagrams , Sequence / Collaboration , DB design In depth test stratergy Psedu-code |