7.11.2012

ASP.NET Difference FAQs

  1. What are the differences between Inline code and Code Behind Code?
S.No
Inline code
Code Behind Code
1
Its within .aspx file
Its in a external class file
2
Dynamically compiled
Compiled prior to deployment and
linked with .aspx file
  1. What are the differences between Global.asax and Web.Config?
S.No
global.asax
web.config
1
It is a class file
It is an XML file
2
There can be only one for an application
There can be many if under different sub-folders
3
Can have Application and Session events
Cannot have Application and Session events
4
Need to be recompiled when changes are made
No need to compile when changes are made
  1. What are the Differences between Server.Transfer and Response.Redirect?
S.No
Server.Transfer
Response.Redirect
1
The navigation happens on the server-side ,so client history is not updated
The navigation happens on the client-side ,so client history is updated
2
Data can be persist across the pages using Context.Item collection
Context.Items loses the persistence
3
No Round-trips
Makes a Round-trip
4
Has Good encapsulation
No
  1. What is the difference between a custom control and a user control?
S.No
User Control
Custom Control
1
Is a file with the .ascx extension
Is a file with the .dll extension
2
Can be only used with the application
Can be used in any number of applications
3
Language dependent
They are language independent, a control
created in c# can be used in vb.net
4
Cannot be added to Visual studio Toolbox
Can be added to Visual studio Toolbox
5
Inherits from Server controls and easy to create
We have to develop from scratch ,
so comparatively
difficult
6
Generally used for static content
Used when dynamic content is required
  1. What is the difference between Caching and Application?
    S.No
    Caching
    Application
    1
    Cache have expire policy
    Application does not have expire policy
    2
    Cache does not require explicit locking
    Application require explicit locking
    3
    Cache has the Property of timeout, which allows us to control the duration of the Objects so cached
    Application variables exist as long as the application is alive
    4
    Output can be cached in 4 ways,
    • Page Output Caching
    • Page Partial Caching
    • DataSource Caching
    • Data Caching
    Application does not have options as like Cache object
    5
    It is accessible to page level to all the users
    It is accessible to both page level and application level to all the users
  2. What is the difference between web farm and web garden?
S.No
Web farm
Web garden
1
A web application running on multiple servers is called a web farm.
A web application running on a single server that has multiple CPUs is called a web garden.The benefit of using this is, if one server crashes then other will work instantly.
2
For Web Garden, we have to use
in Machine.Config file.
Web Farm is implemented using techniques like Net Work Load Balancing.

Summary:

Web garden and web farms are asp.net applications that serve the purpose when the
user base of a web site increases considerably.


For Web garden/Web Farm configurations, we have to set sessionState mode to
StateServer/SQLServer in the web.config file.
  1. What is the difference between Application and Session Events?
S.No
Application Event
Session Event
1
Application events are used to initialize objects and data that we do want to make available to all the current sessions of our web application
Session events are used to initialize data that we want to keep throughout individual sessions, but that we do not want to share between sessions
  1. What is the difference between Session Cookies and Persistent Cookies?
S.No
Session Cookies
Persistent Cookies
1
Session Cookies do not have expiration date
Persistent Cookies have an expiration date. The expiration date indicates to the browser that it should write the cookie to the client’s hard drive
  1. What are the differences between Server Controls and HTML Controls?
    S.No
    Server Controls
    HTML Controls
    1
    Server Controls can trigger control-specific events on the server
    HTML Controls can trigger only page-level events on server (postback)
    2
    Data entered in a server control is maintained across requests. Server controls retain state
    Data is not maintained in an HTML control. Data must be saved and restored using page-level scripts
    3
    The Microsoft .NET Framework provides a set of properties for each server control. Properties allows us to change the server control’s appearance and behavior within server-side code
    HTML controls have HTML attributes only
    4
    Server controls automatically detect browser and adapt display as appropriate
    We must detect browser in code or write for least common denominator
  2. What are the differences between ViewState and Hidden fields?
S.No
ViewState
Hidden fields
1
This is used for pages that will postback to itself
This is used for pages that will postback to itself or to another page
2
This is built in structure for maintaining state of a page
This is not an inbuilt structure
3
Security is more as data is hashed, compressed and encoded
Security is less when compared to ViewState
  1. What is the difference between SQL Cache Notification and SQL Cache Invalidation?
S.No
SQL Cache Notification
SQL Cache Invalidation
1
Using SQL Cache Notification, we can generate notifications when the data of a database on which a cached item depends changes
Using SQL Cache Invalidation, we can make a cached item invalid that depends on the data stored in a SQL server database, when the data in the SQL server database is changed
  1. What is the difference between absolute time expiration and sliding time expiration?
S.No
Absolute time expiration
Sliding time expiration
1
In absolute time expiration, a cached item expires after the expiration time specifies for it, irrespective of how often it is accessed
In sliding time expiration, the time for which the item is cached is each time incremented by its expiration time if it is accessed before completion of its expiration time
  1. What is the difference between adding items into cache through Add() method and Insert() method?
S.No
Cache.Add()
Cache.Insert()
1
Cache.Add() method also returns an object representing the item we have added in the cache ,besides adding the item in the cache
Cache.Insert() method adds only the item in the cache
2
It is not possible to replace an existing item in the cache using the Cache.Add() method
We can replace an existing item in the cache using the Cache.Insert() method
  1. What is the difference between page-level caching and fragment caching?
S.No
Page-level caching
Fragment caching
1
In Page-level caching, we cache a whole page
In Fragment caching, we cache parts of the web page such as a user control added to the web page
  1. What is the difference between Label control and Literal control?
S.No
Label control
Literal control
1
Final HTML code of a Label control has an HTML tag
Final HTML code of a Literal control contains only text, which is not surrounded by any HTML tag
  1. What is the difference between HyperLink control and LinkButton control?
S.No
HyperLink control
LinkButton control
1
A HyperLink control do not have Click and Command events
A LinkButton control have Click and Command events, which can be handled in the code behind file of the web page
  1. What is the difference between an HtmlInputCheckBox control and an HtmlInputRadioButton control?
S.No
HtmlInputCheckBox control
HtmlInputRadioButton control
1
We can select more than one HtmlInputCheckBox control from a group of HtmlInputCheckBox controls
We can select only a single HtmlInputRadioButton control from a group of HtmlInputRadioButton controls
  1. How a content page differs from a master page?
S.No
Content page
Master page
1
A content page does not have complete HTML source code
A master page has complete HTML source code inside its source file
  1. How will you differentiate a submaster page from a top-level master page?
S.No
Submaster page
Top-level master page
1
Like a content page, a submaster page also does not have complete HTML source code
Top-level master page has complete HTML source code inside its source file
  1. What is the difference between a page theme control and a global theme?
S.No
Page theme
Global theme
1
A page theme is stored inside a subfolder of the App_Themes folder of a web application
A global theme is stored inside the Themes folder on a web server
2
It can be applied to individual web pages of the web application
It can be applied to all the web sites on the web server
  1. What is the difference between a default skin and a named skin?
S.No
Default skin
Named skin
1
A default skin does not have a SkinId attribute
A named skin has a SkinId attribute
2
It is automatically applied to all the controls of the same type present on a web page
It is applied to a control explicitly by setting the SkinId property of the control from the Properties window
  1. Differentiate Globalization and Localization
S.No
Globalization
Localization
1
Globalization is the process of identifying the specific portion of a web application that needs to be different for different languages and isolating that portion from the core of the web application
Localization is the process of configuring a web application to be supported for a specific language or locale
2
example:
a)consider this tag in Web.Config file.

It would cause the dates to be displayed in French for the web page of the folder where this Web.Config file is located.

b) CultureInfo d=new CultureInfo("de-DE");
Response.Write(DateTime.Now.ToString("D",d);
It would display date in long format using German culture

example:
we have 2 resource files:
a)default.aspx.fr-FR.resx
b)default.aspx.en-US.resx

Using appropriate coding in the .aspx.cs files of a web page, the strings written in these resource files can be used to change the text of the strings dynamically.

  1. What are the differences between web.config and machine.config?
S.No
web.config
machine.config
1
This is automatically created when we create an ASP.Net web application project
This is automatically installed when we install Visual Studio. Net
2
This is also called application level configuration file
This is also called machine level configuration file
3
We can have more than one web.config file
Only one machine.config file exists on a server
4
This file inherits setting from the machine.config
This file is at the highest level in the configuration hierarchy

No comments:

Post a Comment