1) What is ASP.NET?
·
ASP.NET is a
Server-Side technology which uses object-oriented programming approach. Every
element in ASP.NET is treated as an object and run on the server.
·
ASP.NET allows you to
use a fully featured programming language like C-Sharp (C#) or VB.NET to build
web applications easily.
2) What is Common Language Runtime or CLR?
CLR handles the compilation and execution of
.NET programs. CLR uses JIT and compiles the IL code to machine code and then
executes. Below is the list of responsibilities of Common Language Runtime
-
·
Garbage Collection
·
Code Verification
·
Code Access Security
·
Intermediate language
-to-native translators and optimizer’s
3) What are Assemblies and Namespaces and
explain the difference between them?
Namespaces are the containers for holding the
classes. In Object Oriented world, it is possible that programmers will use the
same class name. By using namespace along with class name this collision can be
removed.
·
An assembly exists as
a .DLL or .EXE that contains MSIL code that is executed by CLR.
·
An assembly contains
interface and classes and it can also contain other resources like files,
bitmaps etc.
4) Describe the Events in the Life Cycle of a
Web Application?
A web application starts, when a browser
requests a page of the application for the first time. The request will be
received by the IIS which then starts ASP.NET worker process. The
worker process then allocates a process space to the assembly and loads it. An Application_Start() event
will fire on start of the application and it’s followed
by Session_Start(). ASP.NET engine then processes the request and sends
back response in the form of HTML to the user and user receives the response in
the form of page.
5) Explain the application event handlers in
ASP.NET?
Below are the event handlers in sequence of
their execution -
·
Application_Start -
Fired when the first user visits a page of the application or first resource is
requested from the server.
·
Application_End -
Fired when there are no more users of the application.
·
Application_BeginRequest
- Fired at the beginning of each request to the server.
·
Application_EndRequest
- Fired at the end of each request to the server.
·
Session_Start - Fired
when any new user visits.
·
Session_End - Fired
when the users stop requesting pages and their session times out.
6) What are the Web Form Events available in
ASP.NET?
Following are the Web Form Events in the
sequence of their execution -
·
Page_Init
·
Page_Load
·
Page_PreRender
·
Page_Unload
·
Page_Disposed
·
Page_Error
·
Page_AbortTransaction
·
Page_CommitTransaction
·
Page_DataBinding
7) What is Global Assembly Cache?
GAC (Global Assembly Cache) is used to share
.NET assemblies. GAC will be used in the below scenarios –
·
If the multiple
application wanted to use the same assembly.
·
If the assembly has
security requirements. For example, if only administrators have the permission
to remove the assembly.
8) Explain the Server Control Events of
ASP.NET?
ASP.NET offers many server controls like
Textbox, Button Dropdown List etc. Each control will respond to the user’s
actions using events and event handler mechanism. Following are the Server
Control Events:
·
Postback events -
These events sends the web page to the server for processing. Once processing
is finished, web page will send data back to the same page on the server.
·
Cached events -
These events are processed when a postback event occurs.
9) What are Strong Names?
Strong names are unique names for assemblies.
Strong name is similar as GUID in COM components. When we want to deploy the
assembly in GAC, then we need to give the strong name for the assemblies.
Strong name helps GAC to differentiate between two versions.
10) Explain the steps to generate the strong
name?
Go to Visual Studio Command Prompt
Type – “sn.exe –k “D:\TestingStrongName.snk” in command prompt.
Once SNK file is generated, sign the project
with this SNK file. Go to project properties and browse the SNK file
generated and build the project.
11) What are the State Management options in
ASP.NET?
Client-side state management - This maintains information on the
client’s machine using either of the following options –
·
Cookies - Cookie
is a small sized text file on the client machine either in the client’s file
system or memory of client browser session.
·
View State - Each
page and control on the page has View State property. This allows automatic
retention of page and control’s state between each trip to server.
·
Query string -
Query strings can maintain limited state information. Data has been passed from
one page to another with the URL, but you can send limited size of data with
the URL.
Server-side state management - This mechanism retains state in the
server. Below are the options to achieve it -
·
Application
State - The data stored in the application object can be shared by all the
sessions of the application.
·
Session State -
Session State stores session-specific information and the information is
visible within the session only.
12) Explain the garbage collection in .NET?
Garbage collection is a CLR feature which
automatically manages memory. CLR automatically releases objects when they are
no longer used and referenced. Following methods are used for garbage
collection –
GC.Collect()
Dispose()
Finalize()
Dispose()
Finalize()
13) What is Reflection in .NET?
Reflection is a mechanism through which types
defined in the metadata of each module can be accessed. The System.
Reflection namespace will have the classes required for reflection.
14) Define Resource Files?
Resource files contains non-executable data like
strings, images etc. that can be used by an application and deployed along with
it. You can change these data without recompiling the whole application.
15) What are different types of caching using
cache object of ASP.NET?
We can use two types of output caching to
cache information that is to be transmitted to and displayed in a Web browser –
·
Page Output Caching
·
Page Fragment Caching
16) How can you cache different version of
same page using cache in ASP.NET?
Output cache functionality is achieved by using
“OutputCache” attribute on ASP.NET page header. It uses following
parameters –
·
VaryByParam -
Caches different version depending on input parameters send through HTTP
POST/GET.
·
VaryByHeader -
Caches different version depending on the contents of the page header.
17) Explain the concept of Globalization and
Localization?
Globalization is used to create a multilingual
application by defining culture specific features like text, date etc.
Localization is used to accommodate the cultural differences in an application.
18) What is Satellite Assemblies?
·
Satellite Assemblies
are the special kinds of assemblies that exist as DLL and contain
culture specific resources in a binary format. They stores compiled localized
application resources. This can be created using the AL utility and can be
deployed even after deployment of the application.
·
Satellite Assemblies
encapsulates the resources into binary format and thus makes resources lighter
and consume lesser space on the disk.
19) What are the
settings that can be done in Web.config file in .NET?
Below are the settings we can have in
web.config -
·
Connection String of
the database.
·
Error Page setting.
·
Culture specific
setting.
·
Session States.
·
WCF Binding and
endpoint details.
·
Error Handling
20) What is Post Back?
There will be a roundtrip of the page between
client and a server in request-response model, so this mechanism is called Post
Back.
21) How do we identify that the Page is
PostBack ?
In server side code we have a property called
"IsPostBack” which is used to identify whether page is posted back
or not. We can set the “AutoPostBack” at the control level where page is
posted back when the state of control is changed.
22) How the ASP.NET events are processed?
ASP.Net events are processed in the following
sequence -
·
Page_Init
·
Page_Load
·
Control events
·
Page_Unload
23) What is AppSetting Section in “Web.Config”
file?
Web.config file defines configuration for a
web project. Using “AppSetting” section we can define user defined
values. Rather than hard coding the values in an application, developers prefer
to keep the key,value pair in appsettings. Below is the sample for adding key
value pair–
<appSettings>
<add key = “yourkey” value=”yourvalue”/>
</appSettings>
<add key = “yourkey” value=”yourvalue”/>
</appSettings>
24) Explain form authentication using login
control?
Login controls encapsulate all the features
offered by Forms authentication. Login controls internally use Forms
Authentication class to implement security, by prompting for user
credentials validating them.
25) Explain Web and Machine configs?
“Web.config” files apply settings to each web
application, while “Machine.config” file apply settings to all ASP.NET
applications. Basically “Machine.Config” at the machine level and “Web.Config”
is at the application level.
26) Explain Session state management options
in ASP.NET?
ASP.NET
provides In-Process and Out-of-Process state
management. In-Process will store the session in memory on the web
server. Out-of-Process will store data in an external data source
such as SQL Server or a State Server service. Out-of-Process requires
that all objects stored in session are serializable.
27) How to turn off cookies for a page?
Cookie.Discard Property when set true
will instruct the client application not to save the Cookie on the user’s hard
disk when a session ends.
28) What is the difference between
Server.Transfer and Response.Redirect ?
Response.Redirect sends message to the
browser saying it to move to some different page,
but Server.Transfer does not send any message to the browser but
rather redirects the user directly from the server itself. So
in ServerTransfer there is no round trip
while Response.Redirect has a round trip and will puts more load on
server.
29) What is the difference between
Authentication and Authorization?
·
Authentication is
the process in which we are checking the identity of the user to allow the user
into the application. So Login is the process of authentication for the
application. Now social media authentication is also allowed in many websites
to identify the user.
·
Authorization sounds
same as authentication but it is different. Authorization handles the
permission stuff for the user at web page level. Better example will be if the
user is authenticated in the website does not mean that user has full
permission on all the pages so that can be controlled by authorization.
30) What are the various ways of
authentication techniques in ASP.NET?
There are basically three types of
authentication modes in ASP.NET –
·
Windows Authentication
– windows authentication uses our system credentials for the authentication
purpose.
·
Forms Authentication –
This is a form based authentication. Login Control in ASP.NET supports this
kind of authentication.
·
Passport
Authentication - Passport authentication lets you to use Microsoft’s passport
service to authenticate users of your application.
31) Explain how to retrieve property settings
from .config file ?
By creating an instance
of AppSettingsReader class, GetValue method is used by
passing the name of the property and the type expected and assign the result to
the appropriate variable.
32) What is side-by-side execution?
This means multiple version of same assembly
can run on the same computer. This feature will enable to deploy multiple
versions of the component.
33) What is application domain?
It is the process space within which the
application will be running. Every application has its own process space which
isolates it from other application. If one of the application domain throws
error, it does not affect the other application domains.
34) What is impersonation in ASP.NET?
ASP.NET executes in the security context of a
restricted user account on the local machine. Sometimes, we need to access
network resources such as a file on a shared drive, which will require
additional permissions. One way to restrict this, is to use impersonation.
ASP.NET with impersonation can execute the request using the identity of the
client or ASP.NET can impersonate a specific account by the values in
web.config.
35) How many types of validation controls are
provided by ASP.NET ?
There are FIVE types of validators in ASP.NET
and they are –
·
RequiredFieldValidator -
It checks whether the control have any value or not. It is used, when you want
the control not to be empty.
·
RangeValidator -
It checks, if the value in validated control is in that specific range. Eg:
Range of Date Birth.
·
CompareValidator -
It checks that the value in controls should match the value in other control.
Eg : Password and Retype Passwords.
·
RegularExpressionValidator -
When we want the control value that matches a specific regular expression. Eg :
Checking for valid Email ID.
·
CustomValidator -
It is used to define User Defined validation.
36) What does AspCompat="true" mean
and when should you use it?
The AspCompat attribute forces the
page to execute in STA mode. ASP.NET runtime throws an exception, if the
compatibility tag is omitted and an STA component is referenced in the page. If
you convert the STA component to an assembly using Tlbimp.exe, runtime does not
detect that the component uses the STA model and does not throw an exception,
but the application can suffer from poor performance.
<%@Page AspCompat=true Language = C# %>
37) What are HttpHandlers?
ASP.NET programming supports the creation of
custom HttpHandler components, which provide an efficient way to
process requests that don't return standard HTML-based pages.
E.g. : HttpHandler components are
good for situations in which you want to return XML, simple text or binary data
to the user.
The easiest way to create a
custom HttpHandler component is to create a source file with an .ashx
extension. You must then add a @WebHandler directive to the top of
the .ashx file with a class definition that implements
the IHttpHandler interface.
38) Explain the differences between Server-side and Clientside code?
38) Explain the differences between Server-side and Clientside code?
·
Server side code is
executed at the server side on IIS in ASP.NET framework, these code will be
written either in C#, VB.NET or VC++.
·
Client side code is
executed on the browser. JavaScript is the typical example for this.
39) What is Custom Control in ASP.NET?
Custom controls are compiled code, which makes
them easier to use but difficult to create one. Once you have created the
control, we can add it to the Toolbox and display it in a visual designer. We
can deploy custom control in GAC and can be shared between the applications.
This is either extended from Control/WebControl class.
40) What is User Control in ASP.NET?
User controls are easy to build, but they are
less convenient to use in complicated scenarios. User controls are developed in
the same way as we develop Web Forms pages in the visual designer. User
controls can handle execution events.
41) What’s a bubbled event?
When you have a complex control,
like GridView, writing an event processing routine for each object like
cell, button, row, etc. is tedious. The controls can bubble up their event
handlers, allowing the main GridView event handler to take care of
its constituents.
42) What is ASP.NET Compilation Tool?
The ASP.NET Compilation tool enables you to
compile an ASP.NET application either In-place or for deployment to a target
location. In-place compilation always helps application performance, because
end users do not encounter a delay on the first request to the application
while the application is compiled. Compilation for deployment can be done in
one of two ways: one that removes all source files, such as code behind files
and markup files, or one that always retains the markup files.
43) What is the basic difference between ASP
and ASP.NET?
The basic difference between ASP and ASP.NET
is that, ASP.NET is compiled whereas ASP is interpreted whereas. This implies
that since ASP mainly uses VBScript, when an ASP page is executed, it is
interpreted. On the other hand, ASP.NET uses .NET languages, such as C#
and VB.NET, which are compiled to Microsoft Intermediate Language (MSIL).
44) In which event, controls will be fully
loaded?
Page load event guarantees that all controls
are fully loaded. Controls are accessed in Page_Init event, but you
will see that view state is not fully loaded during this event.
45) What is the difference between a default
skin and a named skin?
The default skin is applied to all the Web
server controls in a Web form and it does not provide a Skin ID attribute. The
named skin provides an attribute Skin ID and users have to set the Skin ID
property to apply it.
46) What is IIS? Why is it used?
Internet Information Services (IIS) is created
by Microsoft to provide Internet-based services to ASP.NET Web applications. It
makes your system to work as a Web server and provides the functionality to
develop and deploy Web applications on the server. IIS handles the
request-response cycle on the Web server. It offers the service
of SMTP and front-page server extensions. As you
know SMTP is used to send emails and use FrontPage server extensions
to get the dynamic features of IIS, such as form handlers.
47) What you mean by Query String? What are
its advantages and limitations?
The Query String helps to send the page
information to the server. Advantages of Query String are -
·
All browsers works
with Query Strings.
·
Query String would not
not require any server resources so it does not exert any sort of burden on the
server.
Limitations of Query String are -
·
Browser URL does not
support many characters and it has limit.
·
Information will be
visible to the user, which leads to security issues.
48) In ASP.NET how many types of cookies are
there?
There are two types of cookies -
There are two types of cookies -
·
Session
cookie - A session
cookie goes away when the user shuts the browser down.
·
Persistent
cookie - This resides
on the hard drive of the user and is retrieved when the user comes back to the
Web page.
49) What is smart navigation?
Using
the Page.SmartNavigation property, we can enable smart navigation.
When we set the property -Page.SmartNavigation to true, the following
features are enabled for smart navigation. Scroll position of a Web page will
be maintained after postback.
·
Element which focus on
a Web page is maintained during navigation.
·
Most recent Web page
state is only retained in the Web browser history folder.
·
Flicker effect which
could occur on a Web page during navigation will be minimized.
50) Which method has been used in ASP.NET 4.0
to redirect a page permanently?
The RedirectPermanent() method used in ASP.NET 4.0 is used to redirect a page permanently. The below code snippet is an example of the RedirectPermanent() method:
RedirectPermanent("/path/Test.aspx");
51) How can you send an email message in
ASP.NET?
We can use classes - MailMessage and
SmtpMail, which are under namespace System.Net.Mail to send the email
from our Web pages. To send an email through our mail server, we need to create
an object of the SmtpClient class and set the credentials, name of
server and port.
52) Explain methods Response.Write() and
Response.Output.Write()?
·
Response.Write() -
allows you to write the normal output.
·
Response.Output.Write()-
allows you to write the formatted output.
53) What is master page in ASP.NET?
Master Page acts like a normal
page. Master Pages can contain controls, code or markup as in web
form. Master page will have a control called “ContentPlaceHolder”, which
defines region of master page which renders HTML content of child pages which
uses master page. Master pages will have extension ".master" and
there will be a master directive at the top of the page as shown below -
<%@ Master Language="C#"
AutoEventWireup="true" CodeFile="TestOurSite.master.cs"
Inherits=" TestOurSite " %>
54) How does the content page differ from a
master page?
A content page would not be having the
complete HTML source code; whereas a master page has complete HTML source code
inside its source file.
55) Why do you use the App_Code folder in
ASP.NET?
App_Code folder is part of ASP.NET
folders. It stores any type of objects like text files, classes or reports. Advantage
of App_Code folder is that if multiple classes or objects been added
into this folder it creates a single dll for all.
56) What is tracing? Where is it used?
Tracing displays the details about the code
execution. It is meant for getting the details of application when it is in
running mode, which is really useful for troubleshooting the application. It
gives an option to log the details to a file. So from the file it’s easy to
figure out the root cause for an issue. .NET supports Trace Listeners, which
gets the trace output and it is used to store the information in different
places.
57) What is the timeout of Cookie?
The default time for a Cookie to expire is 30
minutes.
58) What are modes of Session state in
ASP.NET?
·
In-Process – It stores the session in local system.
·
State
Server – It stores the
session in a process called “ASP.NET state service”.
·
SQLServer – It stores the session in SQL Server
database.
·
Custom – It allows the custom storage provider.
59) Which namespace is used to implement debug
and trace methods?
Namespace used for both these methods –
“System.Diagnostic”.
60) What are the difference between Web server
and Web Service?
·
Web Server is the
one which gives the response to all the requests of the clients. Client can use
either HTTP, SOAP protocols for request. Web Server is a computer and it turns
to be a server once server software is installed. Every Web Server will have
its domain possibly.
·
Web Services are
one of the components of Web Server which is callable from client side. Client
will call the Web Service by making HTTP or SOAP requests. ASP.NET allows to
create a custom Web Services which is in turn called from client side.
61) How would you enable automatic paging in
DataGrid ?
Below are the list of points which are to be
followed in order to enable paging in Datagrid –
·
Set the “AllowPaging”
to true.
·
Set the current page
index to clicked in PageIndexChanged event.
62) What is difference between Data list, Grid
view and Repeater?
All these controls have many things in common
like Data Source Property, Data Bind
Method ItemDataBound and ItemCreated.
When Data Source Property of a Grid view is
assigned to a Dataset then each Data Row present in the Data Row
Collection of Data Table is assigned to a corresponding DataGridItem and
this is same for the rest of the two controls also. But The HTML code generated
for a Grid view has an HTML TABLE <ROW> element created for the
particular Data Row and it’s a Table form representation with Columns and Rows.
For a Data list it’s an Array of Rows and
based on the Template Selected and the RepeatColumnProperty value we can
specify how many Data Source records should appear per HTML
<table> row. In short in Grid view we have one record per row, where
as in data list we can have five or six rows per row. In Repeater Control
the data records which are to be displayed depends upon the Templates specified
and the only HTML generated is the due to the Templates.
63) What are the difference between adding the
items into cache through the Add () method and through the Insert () method?
·
Cache.Add() will
return an object that represents the item added in the cache.
·
Cache.Insert() is
going to replace the existing item in the cache which will not happen in
Cache.Add().
64) What is the use of "EnableViewState"
property?
This property is used to enable
the ViewState property on the page. It is set to ON, to allow it to
save the input values of the user
between postback requests. When is set to OFF, it won't allow to
save the user input in postbacks.
65) List all different typesS of directives in
.NET?
The different types of directive in .Net –
·
@Import
·
@Page
·
@Control
·
@Register
·
@Reference
·
@Assembly
·
@OutputCache
·
@Implements
66) How to decide on the design consideration
to take a GridView, Datalist or Repeater?
·
GridView provides
ability to allow the end-user to edit the page data or sort the page records.
But it comes at a cost of speed. Secondly, the display format is very simple
i.e. is in row and columns.
·
With its
templates, DataList provides more control over the look and feel of the
displayed data than the GridView. And it offers better performance
than GridView.
·
With Repeater, the
only HTML emitted are the values of the databinding statements in the
templates along with the HTML markup specified in the templates—no
"extra" HTML is emitted, as with theGrdiview and DataList.
67) Which Javascript file is responsible for
validation at the client side?
WebUIValidation.js javascript file is
mainly used for validation by the validators at client side. This file
will be installed at "aspnet_client" at IIS directory.
68) What is .Net Remoting?
.Net Remoting is considered as the
replacement for DCOM. Using .Net remoting remote object calls can be
done which lies in different Application domains. As the remote objects runs
under different process, client which calls remote object cannot call directly.
69) What is Application Domain?
Application Domain is logical boundary created
for .NET applications so that one application does not affect the other
applications. .NET runtime uses Appdomain as a container for data and code.
70) In ASP.NET how many navigation controls
are there?
Navigation controls will be used to navigate
in a Web application. These controls will store the links either in
hierarchical structure or drop-down structure. Navigation controls available in
ASP.NET are –
·
Tree View
·
Menu
·
Sitemap Path
71) What is Delay signing?
During development process, you will need
strong name keys to be exposed to developer which is not a good practice from
security point of view. In these situations you can assign the key later on and
during development, you can use delay signing.
72) What are server-side comments?
Server side comments are used in ASP.NET page.
This is used to describe the purpose of code snippet.
<%--This is how server-side comments can be done -- %>
Server side comments always begins with
“<%--“ and ends with
“-- %>”.
73) What are the common properties of all
validation controls?
·
ControlToValidate –
control name to be validated.
·
ErrorMessage –
error message to be displayed on validation fail.
·
IsValid – Boolean
value for checking control’s validation has succeeded or not.
·
Text – displaying
the text before validation for validation control.
74) What is cross-page posting?
Server.Transfer() method is used for
posting the data from one page to another.
In cross page posting, data collected from
different pages and will be displayed in single page. So, for doing this we
need to set “PostBackUrl” property of the control, in which target page is
specified and in target page we can use “PreviousPage” property. For doing this
we need to set the directive - @PreviousPageType. Previous page control
can be accessed from the method – “FindControl()”.
75) How to differentiate a sub master page
from a top-level master page?
As content page, sub master page will not be
having complete HTML source code. But at top level master page unlike sub
master page it will have complete HTML source code in source file.
76) What’s the difference between Linkbutton
control and Hyperlink control?
·
Link buttons will have
events which can be handled in code behind file.
·
Hyperlink control will
not be having events like click and command events.
77) Where is ViewState information stored ?
Viewstate information is always stored in
HTML hidden fields.
78) What is the significance of Finalize
method in .NET?
.NET Garbage collector does almost all clean
up activity for your objects. But unmanaged resources (ex: - Windows API
Database connection objects, File, created objects, COM objects etc) is outside
the scope of .NET framework we have to explicitly clean our resources. For
these types of objects, .NET framework will
provide Object.Finalize method which will be overridden and clean up
code for unmanaged resources can be put in this section.
79) What are the best ways to send data across
pages in ASP.NET?
Below are the two ways used to send data
across pages in ASP.NET –
·
Public properties
·
Session
80) What are Web Part controls in ASP.NET?
Web part controls are integrated controls
which are used to create a website. This allows the user to change the outlook,
content and state of the pages in browser.
81) What is the use of Global.asax ? and
explain the events in Global.asax ?
It allows to executing ASP.NET application
level events and setting application-level variables.
·
Application_Init
·
Application_Disposed
·
Application_Error
·
Application_Start
·
Application_End
·
Application_BeginRequest
·
Application_EndRequest
·
Application_PreRequestHandlerExecute
·
Application_PostRequestHandlerExecute
·
Applcation_PreSendRequestHeaders
·
Application_PreSendContent
·
Application_AuthenticateRequest
·
Application_AuthorizeRequest
·
Session_Start
·
Session_End
82) How we can copy items of one dropdownlist
to another dropdownlist control?
Foreach ( var listitem in firstdropdownlist.Items)
{
seconddropdownlist.Items.Add(listitem);
}
In the above code we are getting all the items
from first dropdownlist and then add it to the item list of second
dropdownlist.
83) What’s the difference between Literal
control and Label control?
Label control mark up is given below –
<asp:Label ID = "Label1" Text="Label
Test" runat="server" />
·
Label control is
rendered as <span> when rendered as HTML. Label control styles
like font size, font color etc can be changed with very less effort. Javascript
or JQuery also can access the label control very easily.
·
Literal
control rendered as it is. Literal control cannot be styled easily like
label control because it does not render in enclosed HTML tags. Javascript or
Jquery will not be able to access literal control because while rendering it
would not have ID in spite of giving the ID in mark up.
84) Explain the components of web form in
ASP.NET?
Server controls - The server controls are
Hypertext Markup Language (HTML) elements that include a runat=server attribute.
These controls provide automatic state management and server-side events and
respond to the user events by executing event handler on the server.
·
HTML
controls - These controls
also respond to the user events but the events processing happen on the client
machine.
·
Data
controls - Data controls
allows us to connect to the database, execute command and retrieve data from
database.
85) Which are the different IIS isolation
levels in ASP.NET?
IIS has three level of isolation –
·
LOW (IIS
process) - In this, ASP.NET application and main IIS process run in same
process. So, if any application crashes it will adversely affect the others
too.
·
Medium (Pooled) -
In Medium pooled scenario the IIS and web application run in different process.
So in this case there will be two processes process1 and process2. Process1
runs the IIS process and Process2 runs the Web application.
·
High (Isolated) -
Here every process runs under it’s own process. This consumes heavy memory but
has highest reliability.
86) What is Virtual folder?
It is the physical folder that contains web
applications. This folder is used by IIS for web application deployment.
87) Why to use “CustomErrors” section in
config?
CustomError tag gives the details of
custom error messages. CustomError tag can be defined at any level in
application file hierarchy.
<configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="A4academicsError.html"/>
</system.web>
</configuration>
<system.web>
<customErrors mode="RemoteOnly" defaultRedirect="A4academicsError.html"/>
</system.web>
</configuration>
As you can see above customError section has
attribute - "defaultRedirect", which specifies the default
redirection.
88) How to open a page in a new window?
To open a page in a new window, we have to use
client script using onclick="window.open()" attribute of
mainly HTML control.
89) What exactly happens when ASPX page is
requested from Browser?
Following are the steps which will occur when
we request an ASPX page from web server –
·
The browser sends the
request to the webserver. Let’s assume the webserver at the other end is IIS.
·
Once IIS receives the
request, it looks for engine where it can serve this request. When engine means
it’s the DLL which can parse this page or compile and send a response back
to browser. The request which is to be mapped is decided by file extension of
the page requested.
Some File extension mapping given below -
·
.aspx, for ASP.NET Web
pages,
·
.asmx, for ASP.NET Web
services,
·
.config, for ASP.NET
configuration files,
·
.ashx, for custom
ASP.NET HTTP handlers,
·
.rem, for remoting
resources
90) What is the sequence of methods called
during page load?
·
Init() – This method will be used to Initialize
the page.
·
Load() – This method loads the page in server
memory.
·
PreRender() – This method is before page loaded to
the user.
·
Unload() – This method runs once loading of the page
finished.
91) What is Reflection?
Reflection is a mechanism through which types
defined in the metadata of each module can be accessed.
The System.Reflection namespace will have the classes that can be
used to define the types for an assembly.
92) What is the use of
"HttpHandlers" in web.config ?
HttpHandler will be called once the
request comes from client machine. Example: one .aspx or .asmx file is
requested.
<configuration>
<system.web>
<compilation debug="true"/>
<httpHandlers>
<add verb="*" path="*.xsl" type="Handler" />
</httpHandlers>
</system.web>
</configuration>
<system.web>
<compilation debug="true"/>
<httpHandlers>
<add verb="*" path="*.xsl" type="Handler" />
</httpHandlers>
</system.web>
</configuration>
Mapping will be done for the requests to
appropriate handlers based on URL and HTTP request verb.
93) From web.config how to read
connectionstring?
string constr = ConfigurationManager.ConnectionStrings["TestMyconnectionstring"].ToString();
94) What is role based security?
Role Based Security is basically used to
implement security based on roles. We have an option to allow or deny some
roles for our application. Below is the sample code snippet used in web.config
–
<authorization>
<allow roles=”roles to be allowed” <!—Allowing the roles. -->
<deny users =”*”/>
</authorization>
<allow roles=”roles to be allowed” <!—Allowing the roles. -->
<deny users =”*”/>
</authorization>
95) How to apply themes for asp.net
application?
<configuration>
<system.web>
<pages theme=”windows 8”>
</system.web>
</configuration>
<system.web>
<pages theme=”windows 8”>
</system.web>
</configuration>
96) Which are the namespaces used to create a
localized application?
Namesspaces used for localization are –
·
System.Resources and
·
System.Globalization
97) Can we use different programming languages
in the same web application?
Yes of course we can do it. We can create some
web pages with C# language and some pages in VB.NET but the same is false when
we mix up multiple programming languages in the same project because each
project will be built to a single dll.
98) How can we change a Master Page at
runtime?
Using page events we can change the master
page during runtime. In Page_PreInit() event we can change the master
page by setting the “MasterPageFile” property to the path of the master page
what we have to set.
99) What are Application Pools?
Once the web application is deployed into IIS,
we can set the Application Pool to the website directory where web application
hosted/deployed. Application Pool is assigned to the website to make it secure
and confidential. Multiple websites can be assigned under a single application
pool which in turn will be under a single worker process. (Multiple worker
process can also be assigned for a single application pool in the settings).
100) Why “AutoEventWireup” is used?
AutoEventWireup is used for wiring up the
events in page so that it can be given at the page level. Value of this
attribute is Boolean (true or false). By default it is set to “true” for
C# web form where as, it is “false” for VB.NET web forms.
101) Performance wise which is better, Session
or ViewState?
·
For large amount of
data, Session will be an efficient way to go. When session is not
used, set it to null for memory overhead but this cannot be done in all the
cases. Once the session timeout happened it automatically set to null. Default
timeout is 20 minutes.
·
In Viewstate, all
data will be stored in HTML hidden fields. For large amount of data, it would
give performance issues. Ideal size of viewstate should not be more than 20-30%
of page size. So for less data viewstate will be an ideal solution.
102) How to display all validation messages in
validation controls?
By adding ValidationSummary control
to web page we can display all the validation messages related to different
validation controls.
103) Why to use "Orientation"
property of Menu control?
Orientation property is used to set the
display of menu vertically or horizontally. By default the value of this
property is vertical.
104) How to kill a user session?
When a user logs into the website, it’s a good
practice to create a new session to track the user activities. So, meantime we
need to handle log out scenario as well. So, we will kill a user
session once user logs out of the application. Below is the code snippet
that can be written to kill the user session –
·
Session.Abandon();
105) How to use a checkbox in a gridview?
Following are the steps to be used.
Add Itemtemplate tag in gridview like below -
<ItemTemplate>
<asp:CheckBox id="TestMyCheckBox" runat="server" AutoPostBack="True" OnCheckedChanged="Check_Clicked"></asp:CheckBox>
</ItemTemplate>
<asp:CheckBox id="TestMyCheckBox" runat="server" AutoPostBack="True" OnCheckedChanged="Check_Clicked"></asp:CheckBox>
</ItemTemplate>
If you look at the Itemtemplate we
have “OnCheckChanged” event. This “OnCheckChanged” event has “Check_Clicked”
subroutine which actually resides in behind code and this method should either
be “protected” or “public”. Sample code snippet shown below –
Protected Sub Check_Clicked(ByVal senderobj As Object, ByVal e
As EventArgs)
// do something
End Sub
// do something
End Sub
106) How can we format data inside Gridview?
We can format data using – “DataFormatString”
property.
107) How do you upload a file in ASP.NET?
ASP.NET provides two controls that lets user
to upload files to server. Once web server receives the file, it can take any
actions on that file. Controls used for uploading file are –
·
FileUpload – This is an ASP.NET control.
·
HtmlInputFile – This is HTML Server control.
108) What are the common properties Button
controls used in ASP.NET?
Following are the list of properties used –
·
Text – This property is used to display the
text of button.
·
CausesValidation – This property is used to determine
whether validation occurs in page once button is clicked.
·
ImageUrl – This property is used for displaying
the image on button control.
·
CommandName - This property is used to get or set
the command name associated to button control.
·
CommandArgument – This property is used for passing the
string value to command event once user clicks on button.
109) What is a component?
Component is a group of classes and methods
which are logically related. Component should
implement IComponent interface or at least uses class that
implemented IComponent interface.
110) How to force all the validation control
to run?
Page.Validate method is used to force all
the validation controls to run.
111) If client side validation is enabled in your Web page, will that mean server side code does not run?
When client side validation is enabled, server
emits JavaScript code for the custom validators. But, it does not mean that
server side checks on custom validators do not execute. It does this check two
times as some of the validators do not support client side scripting.
112) How can I show the entire validation
error message in a message box on the client side?
This can be done by setting “ShowMessageBox”
to true of validation summary.
113) How to validate textbox for zero value?
Below is a code snippet for custom validator,
which is checking whether a textbox have a zero value –
<asp:CustomValidator id="MyTestCustomValidator"
runat="server"
ErrorMessage="Divided by Zero Error"
ControlToValidate=" txtTestMyNumber"
OnServerValidate="ServerValidate"
ClientValidationFunction="CheckZero" />
<asp:TextBox id="txtTestMyNumber" runat="server" />
runat="server"
ErrorMessage="Divided by Zero Error"
ControlToValidate=" txtTestMyNumber"
OnServerValidate="ServerValidate"
ClientValidationFunction="CheckZero" />
<asp:TextBox id="txtTestMyNumber" runat="server" />
<script language="javascript">
function CheckZero(source, args)
{
int val = parseInt(args.Value, 8);
if (val ==0)
{
args.IsValid = false;
}
}
</script>
As shown above “txtNumber” is the text box
name where in value will be entered and client script “CheckZero” checking for
zero value.
114) If cookies are not enabled at browser end
does Form Authentication work?
No. it will not work. Form authentication
wants cookies to be enabled.
Reason – First time user will send its credentials to server and
user will then be authenticated and server gives a response and this will be
stored in client machine mainly as cookie. But if cookies are disabled, this
would not be stored. For the second time, the same user will not be
authenticated.
115) How do I sign out in forms
authentication?
FormsAuthentication.Signout() method is
used to sign out.
116) What are design patterns?
It is recurring solution to recurring problems
in software architecture.
117) Can you list down all design patterns?
Below are the list of design patterns along
with their classifications -
Creational Design Pattern
·
Abstract Factory
·
Builder
·
Factory Method
·
Singleton
·
Prototype
Structural Design Patterns
·
Composite
·
Adapter
·
Flyweight
·
Proxy
·
Decorator
·
Bridge
·
Façade
Behavioral Design Patterns
·
Interpreter
·
Iterator
·
Command
·
Observer
·
Mediator
·
Template Method
·
Strategy
·
Chain of
Responsibility
·
State
·
Memento
·
Visitor
118) How to customize columns in GridView?
Gridview have the ability to generate
required columns automatically using BoundField. But, we can manually
create column which are to be customized instead of auto generating. For
customizing columns “TemplateField” will be used.
119) Can we use COM components in .Net? If so,
how can we use?
“Runtime Callable Wrapper” (RCW) can be
used for making communication between COM components and .NET components.
This can used in following ways –
·
Create a wrapper class
and put it in BIN directory.
·
Use type library
importer tool - Tlbimp.exe
·
Use
namespace System.Runtime.Interopservices , which gives converter (TypeLib)
which has all methods which are required to convert COM classes to assembly
metadata.
120) How can I show the entire validation
error message in a message box on the client side?
This can be done by adding validation summary
control. In Validation Summary control, there is a property “ShowMessageBox”
just set it to true.
121) List down the differences between Debug
and Trace in ASP.NET?
Both these methods are under namespace
- System.Diagnoastics.
·
Debug – This works only when the mode is
Debug.
·
Trace – This works in both Debug and Release
modes.
122) What is the difference between Process
and Thread?
·
Process is
collection of system resources, data, code and memory space.
·
Thread is a code
which is executed in process. One process can have multiple threads along with
primary thread. Thread will be executed until it’s killed or higher priority
thread comes for an execution. Each thread will share resources of a process in
which it is running.
123) What is the difference between cache
object and session object?
·
Cache – This improves the performance by
minimizing the database hits to fetch the data. It instead stores the data
in cache. So cache will be checked first for data and if it is not found then
go to database to get the data.
·
Session – Session will be created to store the
details of the user for capturing the user’s specific actions. Session will be
killed or it will be expired in 20 minutes.
125) List down at least five Gridview events?
GridView Events are as below –
·
PageIndexChanging -
This event will be fired when pager button is clicked and before Gridview
control handles this operation.
·
PageIndexChanged -
This event will be fired when pager button is clicked and after Gridview
control handles this operation.
·
RowCommand - This
event will be fired when any button is clicked in Gridview.
·
RowDataBound -
This event will be fired when data is bounded to GridView.
·
RowCreated - This
event will be fired when row is created in GridView.
·
RowDeleted - This
event will be fired when row is deleted in GridView.
126) How many object are there in ASP.NET?
There are six objects are there in ASP.NET and
they are following –
·
Session
·
Request
·
Response
·
Object Request
·
Server
·
Application
127) Why PDB files are useful?
PDB files are useful for debugging. PDB files
contain the debug information and project information. When project is
built under Debug mode PDB files are generated and it would not generate in
Release mode. These files should not be included in production deployment.
128) What is ASP.NET membership?
ASP.NET membership allows you to store and
validate the user credentials. Forms Authentication can be used for storing the
user credentials in ASP.NET membership using login controls of ASP.NET.
Membership supports storing user credentials in SQL Server , Active
Directory etc.
129) How to disable Session at the Page Level?
<%@ Page language="c#"
Codebehind="TestMyPage1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.TestMyPage1 "
EnableSessionState="false" %>
AutoEventWireup="false" Inherits="WebApplication1.TestMyPage1 "
EnableSessionState="false" %>
Using “EnableSessionState” property we can
disable the session at page level as shown above.
130) How we can handle SQL Exceptions in
ASP.NET?
We can use try, catch and finally block for
error handling. Use SqlException class to handle exceptions specific
to SQL Server.
try
{
//some code
}
catch(SQLException ex)
{
//Handle SQL Exception
}
{
//some code
}
catch(SQLException ex)
{
//Handle SQL Exception
}
131) How to set maximum length of Textbox in
ASP.NET?
Textbox maximum length can be controlled from
“MaxLength” property. By default length of the textbox will be 65535.
132) How many validations can be applied on customer’s “Age” field?
132) How many validations can be applied on customer’s “Age” field?
Two validations can be applied for this field
and they are –
·
Required – For
checking mandatory value.
·
Range – For checking
the age range, age should be between the ranges.
133) What is the difference between Web
Services and Remoting?
Both these applications support distributed
applications.
·
Remoting is used
to talk in binary format and is not cross platform. It expects consumer to be
.NET application. It uses SMTP, HTTP and TCP protocols for communication.
·
Web Services can
be either WCF or XML Web Services. Web Services are hosted in internet and it
is cross platform. Client will be created for using web service and client can
consume the methods of web service.
134) Why to use web.sitemap in ASP.NET?
For using navigation controls like menu,
treeview etc we have to define xmlsitemap, which is called
web.sitemap.
Eg :
<?xml version="1.0" encoding="utf-8"?>
<siteMap
xmlns=" ">
<siteMapNode url="~/Home.aspx" title="Home" description="">
<siteMapNode url="~/ About.aspx" title="About"
description=""/>
<siteMapNode url="~/ Details.aspx" title="Details"
description=""/>
<siteMapNode url="~/ Contact.aspx" title="Contact"
description="" >
<siteMapNode url="~/ Comment.aspx" title="Comment"
description=""/>
</SiteMapNode>
</SiteMapNode>
</SiteMap>
<?xml version="1.0" encoding="utf-8"?>
<siteMap
xmlns=" ">
<siteMapNode url="~/Home.aspx" title="Home" description="">
<siteMapNode url="~/ About.aspx" title="About"
description=""/>
<siteMapNode url="~/ Details.aspx" title="Details"
description=""/>
<siteMapNode url="~/ Contact.aspx" title="Contact"
description="" >
<siteMapNode url="~/ Comment.aspx" title="Comment"
description=""/>
</SiteMapNode>
</SiteMapNode>
</SiteMap>
135) Is it possible to use multiple web.config
files of ConnectionString in one page?
Yes. We can have multiple web.config in an
application. But these web.config files should be under different folders, it
should not be in same place in an application.
136) Why to use UpdatePanel control in AJAX
ASP.NET?
AJAX is a client side technology and it
supports asynchronous communication between client and server. If the part of
page need to be refreshed, then we can use this Update panel control, which
uses AJAX request and does not harm the other part of the page.
137) How can I disable the Session at page
level and at the application level?
Disabling Session at page level –
<%@ Page language="c#"
Codebehind="MyPageTesting1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1. MyPageTesting1"
EnableSessionState="false" %>
AutoEventWireup="false" Inherits="WebApplication1. MyPageTesting1"
EnableSessionState="false" %>
Disabling Session at application level
– This can be done in Web.Config of our application in following way.
<sessionstate mode="off"> under
<system.web>
138) Why to set the property – EnableViewState
to true?
Purpose of view state is to persist the state
across postback. “EnableViewState” property is available at control and page
level. Once we set it to TRUE, viewstate for a Control/Page will be enabled.
139) Why to use “runat=server” for HTML element?
HTML elements are treated as text by default. Once we add “runat=server” attribute to HTML element, it will be treated as a server control. If we add “runat=server” attribute we have to make sure this element is in <form> tag because it indicates that form is processed by server.
140) Can we store the dataset into viewstate?
If yes, how?
Yes we can store the dataset into viewstate.
We have to serialize the dataset and store it into viewstate.
141) How can we convert sql2000 numeric to
integer in ASP.NET?
sqlParameter objTest=new sqlParameter();
objpara=objDataadapter.UpdataCommand.Parameter.Add("@Quantity",SqlDbType.Int);
objpara.SourceColumn="Quantity";
objTest.SourceVersion=DataRowVersion.Current;
objpara=objDataadapter.UpdataCommand.Parameter.Add("@Quantity",SqlDbType.Int);
objpara.SourceColumn="Quantity";
objTest.SourceVersion=DataRowVersion.Current;
142) What you mean by DocType in ASP.NET?
XHTML Web pages should
contain DOCTYPE, which identifies the page as XHTML. ASP.NET would
not create DOCTYPE declaration when it’s rendered.
143) What is meant by runtime hosts?
Runhosts are special type where CLR is
managed and executed.
144) What you mean by HTTPContext?
This is in System.Web namespace,this is
the best way for reading server response at runtime.
Eg: HttpContext.Current.Items.Add("ERRORMESSAGE ",
exception.Message);
145) Why to use Hidden Fields in ASP.NET?
Hidden fields are best way for exchanging the
data between client (browser) and server. These controls are not visible in web
page but can be accessed from javascript or Jquery.
146) What is the difference between Hidden
Field and Textbox with Visible=false?
Hidden Field can be accessed
from javascript or Jquery, whereas Textbox with Visible =
false is not accessible from javascript or Jquery.
147) How do you decide on when to go for
caching?
In case in our application, we need to store
large amount of data and if it is the master data (which does not change most
often) then we can use caching for storing this data.
148) What is the role of CSS in web pages in ASP.NET?
148) What is the role of CSS in web pages in ASP.NET?
Cascading Style Sheet (CSS) is used to style
the pages or controls which is visible to the user. CSS can be created in .css
files and can be included this in our web pages.
149) What does mean Stateless?
Stateless mean, if the entity does not
remember its previous state. HTTP is stateless protocol because it does not
remember its old state (request) done. For this stateless feature ASP.NET
provides state management options like Session, Cookies, Viewstate etc.
150) What does partial mean in ASP.NET?
We have the option of splitting the single
class file into multiple parts. Using partial keyword, we can split the logic
of single class into multiple class files with the same class name. Advantage
of this would be – We will end up creating only one object for the class.
151) What could be best way to handle the data
more than 10k in Datagrid?
Using dataset would be a feasible solution. Dataset will
again have datatables in it. It’s easy to
use LINQ to Dataset to filter the data from dataset and
binding it to Datagrid.
152) Explain Page.IsValid?
This property will let you know whether all
validation in a page succeeded or not.
153) Is it possible to use javascript from
codebehind files in ASP.NET?
Yes we can register
the javascripts from codebehind files like below –
Use method
- Page.RegisterStartupScript() or
use Page.RegisterClientScriptBlock().
154) How to use MessageBox without javascript
in ASP.NET?
Add the reference of System.Windows.Forms
library then use the method –
MessageBox(“Hi Testing”);
155) How can we change the timeout of session
in ASP.NET?
Basically timeout of session is 20 minutes and
if we want to change this timeout we can do in following way –
·
Change the Session
time out in web.config. (In sessionstate tag change the timeout)
·
Change the Session
time out in code using timeout property of session class.
2 Comments
very good question ans.
ReplyDeleteHello Everyone !
ReplyDeleteUSA SSN Leads/Fullz available, along with Driving License/ID Number with good connectivity.
All SSN's are Tested & Verified.
**DETAILS IN LEADS/FULLZ**
->FULL NAME
->SSN
->DATE OF BIRTH
->DRIVING LICENSE NUMBER
->ADDRESS WITH ZIP
->PHONE NUMBER, EMAIL
->EMPLOYEE DETAILS
*Price for SSN lead $2
*You can ask for sample before any deal
*If you buy in bulk, will give you discount
*Sampling is just for serious buyers
->Hope for the long term business
->You can buy for your specific states too
**Contact 24/7**
Whatsapp > +923172721122
Email > leads.sellers1212@gmail.com
Telegram > @leadsupplier
ICQ > 752822040