1. ASP.NET? What are the Advantages of Asp.Net
Applications?
ASP.NET is a server side technology
which is introduced by Microsoft.
It used to build dynamic websites,
Web applications and Web services and it derived from the Microsoft Active Server Pages (ASP) and
adapted for use in the .NET
Framework.
Also called managed ASP and formerly known as ASP+.
Advantages:
·
Asp.Net is purely a server side technology and
completely object oriented which makes development, deployment and maintenance
of the applications easily when compared to Classic Asp.
·
It Provides High scalability, Authentication and
better performance.
·
Execution is fast as the source code of page is
compiled for the first time when it is requested and it uses the compiled
version of page for next time.
·
Full support over Ado.Net, EF for quicker data binding
and of XML, Json for easy data exchange.
2. What is ViewState?
·
ViewState is one of the client side state management
techniques in .Net to store posted data among post backs.
·
It is a built in structure to retain the values of
server side objects in client side (hidden field) and transported back to
server whenever required during post backs of the same page.
·
Sample code of implementing
ViewState
//Assigning…………………………………
this.ViewState[“EnterTime”]= DateTime.Now.ToString();
//Utilizing………………………………….
lblTime.Text = this.ViewState[“EnterTime”].ToString();
3. What are benefits and limitations of ViewState?
Benefits:-
·
No server resources are required as they are stored in client.
·
States are retained automatically among multiple post backs for the
same page.
·
Values of the ViewState can be hashed, compressed and encoded thus
representing better security than Hidden fields.
Limitations:-
·
Page loading and posting performance decreases when large values are
stored because view state is stored in the page.
·
Though the View state values stored in the hashed format, it can be
tampered thus creating a security hole.
4.
Describe the
difference between inline and code behind.
The Inline code can be written
inside the script tag of html in an .aspx page. Whereas, the Code-behind is
code written in a separate file (.cs or .vb) and referenced by the .aspx page.
5.
What is a Page
Life Cycle of an ASP.Net page?
There are various stages described as under.
·
PreInit
·
Init
·
LoadViewState
·
LoadPostBackData
·
Load
·
RaisePostBackEvents
·
Pre-Render
·
SaveViewState
·
Render
·
Unload
6. Explain the differences between
Server-side and Client-side code?
·
The Code that executes on the server is the Server
side code, whereas the code executes on the browser is the Client side code.
·
Server-side code executes on the server before it is
sent to the browser. Client-side scripting executes in the browser after the
page is loaded.
E.g. for server side code is
Asp.Net and for Client side code is JavaScript, VbScript.
7. What is Authentication and Authorization?
Authentication is the process of
identifying/validating the user against the credentials (username and
password).
Authorization is the process of
granting access to the specific resource for those authenticated users. Authorization is performed after
authentication.
8. What are the types of Authentication? Describe.
There are 3 types of Authentication. Windows, Forms and Passport Authentication.
·
Windows authentication uses the security features
integrated into the Windows operating systems to authenticate and authorize Web
application users. It is the default
authentication mode.
·
Forms authentication allows you to create your own
list/database of users and validate the identity of those users when they visit
your Web site.
·
Passport authentication uses the Microsoft centralized
authentication provider to identify users. Passport provides a way to for users
to use a single identity across multiple Web applications. To use Passport
authentication in your Web application, you must install the Passport SDK.
Sample code: In web.config
file.
<system.web>
<authentication
mode=”Forms”/>
</system.web>
·
Web server controls
·
Html controls
·
User controls
·
Custom controls
10. What’s the Difference between Server controls and
Html controls?
·
Server controls provides better functionality and rich
object model over Html controls.
·
Html controls are light weighted one.
·
Server controls can persist state information across
multiple requests of the same page, whereas Html controls cant.
·
Server controls can raise controls Events like click,
text changed, selected item on the server, whereas Html controls cant.
11.
What
is difference between user control and custom control?
·
User Control is a page file with .ascx extension which
can only be used within a single application. But custom controls are
assemblies (dll files) that can be used in multiple applications.
·
User Controls cannot be added to the ToolBox of VS.NET
. To use a user Control within an aspx page u have to drag the user Control
from the solution Explorer to designer page. But Custom Controls can be added
to ToolBox of VS.NET.
·
User controls
are created from existing Webserver and html server controls. But creating custom controls have to render
everything from the scratch.
12.
What
is the difference between master page and user control?
Master page is
a template for the page; it allows creating a consistent layout for all pages
in the application.
User Control is
a page file with extension .ascx and can use it anywhere on your page and as
many as you want.
13.
What
are the different types of Validation Controls?
There are six types of validation controls available:
·
RequiredFieldValidator
It checks whether the control have any value.
It's used when the control should not be empty.
·
RangeValidator
It checks if the value in validated control is
in that specific range.
·
CompareValidator
It checks that the value in
controls should match the value in other control or with a constant value.
·
RegularExpressionValidator
When we want the control
value should match with a specific regular expression.
·
CustomValidator
It is used to define User
Defined validation.
·
ValidationSummary
It displays summary of all
current validation errors.
14.
What
is the difference between Application_start and Session_start?
·
The Application_Start and Session_Start are the events
which were defined in the Global.asax file
·
Application_start gets fired when an application
receive the very first request. It is guaranteed to occur only once throughout
the lifetime of the application. It’s a good place to initialize global
variables.
·
Session_start gets fired for each of the user session.
15. What is the difference between SessionState and
ViewState?
Session state refers to user specific data
that can be accessed across all pages in the web application.
View State is specific to a page in a session.
16.
What are the
various modes of storing ASP.NET session?
InProc:- In this mode Session state is
stored in the memory space of the Aspnet_wp.exe process. This is the default
setting.
If the IIS reboots or web
application restarts then session state is lost.
StateServer:-In
this mode Session state is serialized and stored in a separate process
(Aspnet_state.exe); therefore, the state
can be stored on a separate computer(a
state server).
SqlServer:- In this mode Session state is serialized and stored in
a SQL Server database.
Session state can be specified in <sessionState>
element of application configuration file. Using State Server and SQL SERVER
session state can be shared across web farms but note this comes at speed cost
as ASP.NET needs to serialize and deserialize data over network again and
again.
17.
Master Page
ASP.NET master page provides a
consistent layout and define the look and feel and standard behavior for
the pages in your application. When
users request the content pages, they merge with the master page to produce
output that combines the layout of the master page with the content from the
content page.
-> .master file extension
-> The master page contains @Master directive,
which replaces the @Page directive that is used for ordinary aspx page.
18.
What are the
Types of State Management techniques in Asp.Net?
There are several ways to manage state information in Asp.Net.
·
View State
·
Control State
·
Query String
·
Cookies
·
Hidden Field
·
Session
·
Application
·
Profile
19. What is a cookie. What are benefits and
limitations of using Cookies?
Cookies are small pieces of information stored on the client computer.
It is generally used to store user preferences or any other client-specific
information.
Two different types of Cookies are:
->Session Cookies
Session cookies are
stored in-memory during the client browser session. When the browser is closed
the session cookies are lost.
->Persistent Cookies
->Persistent Cookies
Persistent cookies
are generally used to store information that identifies a returning user to a
Web site. Typical information found in Persistent Cookies includes user names
or user IDs.
Sample code:-
Request.Cookies.Add(New
HttpCookie(“name”, “user1”))
Benefits:-
·
No server resources are required as they are stored in
client.
·
They are light weight and simple to use
Limitations:-
·
Size of cookies has been restricted upto 8Mb.
·
Cookies can be tampered and thus creating a security
hole.
·
Cookies can expire thus leading to inconsistency.
·
Some users disable their browser or client device’s
ability to receive cookies, thereby limiting the use of cookies.
20. What is cookie less session? How it works?
If cookies are not available, a session can be
tracked by adding a session identifier to the URL.
This can be
enabled by setting the following:
<sessionState cookieless="true" />
21. What is Query String? What are benefits and
limitations of using Query Strings?
A
query string is information sent to the server appended to the end of a page
URL. It provides a simple but limited way of maintaining state information
which contains parameters as Name-value pairs.
Benefits:-
·
No server
resources are required.
·
All browsers
support query strings.
Limitations:-
·
Query string
data is directly visible to user thus leading to security problems.
·
Most browsers and client devices impose a
255-character limit on URL length.
22.
What’s
the difference between Cache object and application object?
Application and Cache both help to
share global data. The Cache objects differ from the Application objects
in the way, that it provides cache-specific features, such as dependencies and
expiration policies.
CacheDependency objCacheDependency = new
CacheDependency(Server.MapPath("Banner.txt"));
Cache.Insert("Banner", strBanner, objCacheDependency);
Application["Banner"]
= "strBanner";
In the above code, for Cache object you
can define dependency but in Application object you can't define dependency.
When the banner file is changed the Cache object can
be refreshed but the application remains static and holds the old text of
banner file.
23.
What
is Caching? What are the different types of Caching?
Caching is
the technique of storing frequently used items in memory so that they can be
accessed more quickly. Caching is important to Web applications because each
time a Web form is requested, the host server must process the Web form’s HTML
and run Web form code to create a response. By caching the response, all that
work is bypassed and the request is served from the response already stored in
memory.
There are three types of Caching:
·
Output Caching: Page output caching adds the
response of page to cache object. Later when page is requested page is
displayed from cache rather than creating the page object and displaying it.
Page output caching is good if the site is fairly static
·
Fragment Caching: Only caches/stores the
portion of page (User Control)
·
Data Caching: Is Programmatic way to Cache objects for
performance.
24.
How
can get access to cache object?
The Cache object is defined in the
System.Web.Caching namespace. You can get a reference to the Cache object by
using the Cache property of the HttpContext class in the System.Web namespace
or by using the Cache property of the Page object.
25.
What
are dependencies in cache and types of dependencies?
When
an item is added to the cache, dependency relationships can be defined that can
force the item can be removed from the cache under specific activities of
dependencies. Example if the cache object is dependent on file and when the
file data changes you want the cache object to be update.
Following are the supported dependency:-
√
File dependency: - Allows you to
invalidate a specific cache item when a disk based file or files change.
√
Time-based expiration: - Allows you
to invalidate a specific cache item depending on predefined time.
√ Key
dependency:-Allows you to invalidate a specific cache item depending when
another cached item changes.
26.
How will
implement Page Fragment Caching?
Page
fragment caching involves the caching of a fragment of the page, rather than
the entire page.
When portions of the page are
need to be dynamically created for each user request this is best method as
compared to page caching. You can wrap Web Forms user control and cache the
control so that these portions of the page don’t need to be recreated each
time.
27.
What
are the exception-handling ways in ASP.NET?
·
By using try - catch block at Method Levels.
·
By using the Server object’s GetLastError() and
ClearError() methods at Page Levels.
·
Using Error event procedures in global.asax file and
customerror tag in web.config file at the Application levels.