0% found this document useful (0 votes)
35 views

Session Variables?

Uploaded by

vinodg_2009
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Session Variables?

Uploaded by

vinodg_2009
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

(B) What are ASP.NET session and compare ASP.

NET session with classic ASP


session variables?

ASP.NET session caches per user session state.It basically uses


“HttpSessionState” class. Following are the limitations in classic ASP sessions :-
√ ASP session state is dependent on IIS process very heavily.So if IIS restarts
ASP session variables are also recycled.ASP.NET session can be independent of
the hosting environment thus ASP.NET session can maintained even if IIS
reboots. √ ASP session state has no inherent solution to work with Web
Farms.ASP.NET session can be stored in state server and SQL SERVER which
can support multiple server. √ ASP session only functions when browser
supports cookies.ASP.NET session can be used with browser side cookies or
independent of it.

(B) Which 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.92 √ 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). √ SQL SERVER:- 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.

(A) Is Session_End event supported in all session modes ?


(B) Session_End event occurs only in “Inproc mode”.”State Server” and
“SQL SERVER” do not have Session_End event.

(A) What are the precautions you will take in order that StateServer Mode
work properly ?

Following are the things to remember so that StateServer Mode works


properly :- √ StateServer mode session data is stored in a different
process so you must ensure that your objects are serializable. √
<machineKey> elements in Web.config should be indentical across all
servers.So this ensures that encryption format is same across all
computers. √ IIS metabase (\LM\W3SVC\2) must be identical across all
servers in that farm.

(A) What are the precautions you will take in order that SQLSERVER
Mode work properly ?

Following are the things to remember so that SQLSERVER Mode


works properly :- √ SQLSERVER mode session data is stored in a
different process so you must ensure that your objects are
serializable. √ IIS metabase (\LM\W3SVC\2) must be indentical
across all servers in that farm.93 √ By default Session objects are
stored in “Tempdb” , you can configure it store outside “TempDB”
by running microsoft provided SQL script. Note :- “TempDB”
database is re-created after SQL SERVER computer reboot.If you
want to maintain session state with every reboot best is to run SQL
Script and store session objects outside “TempDB” database. (A)
Where do you specify session state mode in ASP.NET ?
<sessionState mode=”SQLServer”
stateConnectionString=”tcpip=192.168.1.1:42424"
sqlConnectionString=”data source=192.168.1.1; Integrated
Security=SSPI” cookieless=”false” timeout=”20" /> Above is sample
session state mode specified for SQL SERVER.

(B) What are the other ways you can maintain state ?

Other than session variables you can use the following technique to
store state : √ Hidden fields √ View state √ Hidden frames √ Cookies
√ Query strings

(C) What are benefits and Limitation of using Hidden fields ?

Following are the benefits of using Hidden fields :- √ They are simple
to implement. √ As data is cached on client side they work with Web
Farms. √ All browsers support hidden field. √ No server resources
are required. Following are limitations of Hidden field :-94 √ They
can be tampered creating a security hole. √ Page performance
decreases if you store large data , as the data is stored in pages
itself. √ Hidden fields do not support rich structures as HTML hidden
fields are only single valued.Then you have to work around with
delimiters etc to handle complex structures. Below is how you will
actually implement hidden field in a project <input
id="HiddenValue" type="hidden" value="Initial Value"
runat="server"NAME="HiddenValue">

(B) What is ViewState ?

Viewstate is a built-in structure for automatically retaining values


among multiple requests for the same page. The view state is internally
maintained as a hidden field on the page but is hashed, providing
greater security than developer-implemented hidden fields do.

(A) Do performance vary for viewstate according to User controls ?

Performance of view state varies depending on the type of server


control to which it is applied. Label, TextBox, CheckBox,
RadioButton, and HyperLink are server controls that perform well
with ViewState. DropDownList, ListBox, DataGrid, and DataList suffer
from poor performance because of their size and the large amounts
of data making roundtrips to the server.

(B) What are benefits and Limitation of using Viewstate for state
management?

Following are the benefits of using Viewstate :- √ No server


resources are required because state is contained in a structure in
the page code. √ Simplicity. √ States are retained automatically. √
The values in view state are hashed, compressed, and encoded, thus
representing a higher state of security than hidden fields.95 √ View
state is good for caching data in Web farm configurations because
the data is cached on the client. Following are limitation of using
Viewstate:- √ Page loading and posting performance decreases when
large values are stored because view state is stored in the page. √
Although view state stores data in a hashed format, it can still be
tampered with because it is stored in a hidden field on the page. The
information in the hidden field can also be seen if the page output
source is viewed directly, creating a potential security risk. Below is
sample of storing values in view state. this.ViewState["EnterTime"] =
DateTime.Now.ToString();

(C) How an you use Hidden frames to cache client data ?

This technique is implemented by creating a Hidden frame in page


which will contain your data to be cached. <FRAMESET
cols="100%,*,*"> <FRAMESET rows="100%"> <FRAME
src="data_of_frame1.html"></FRAMESET> <FRAME
src="data_of_hidden_frame.html"> <FRAME
src="data_of_hidden_frame.html" frameborder="0" noresize
scrolling="yes"> </FRAMESET> Above is a sample of hidden frames
where the first frame “data_of_frame1.html” is visible and the
remaining frames are hidden by giving whole col section to first
frame. See allocation where 100 % is allocated to first frame and
remaining frames thus remain hidden.

(I) What are benefits and Limitation of using Hidden frames?

Following are the benefits of using hidden frames: √ You can


cache more than one data field.96 √ The ability to cache and
access data items stored in different hidden forms. √ The
ability to access JScript® variable values stored in different
frames if they come from the same site. The limitations of
using hidden frames are: √ Hidden frames are not supported
on all browsers. √ Hidden frames data and be tampered thus
creating security hole.

What are benefits and Limitation of using Cookies?

Following are benefits of using cookies for state management :- √ No


server resources are required as they are stored in client. √ They are
light weight and simple to use Following are limitation of using cookies :-
√ Most browsers place a 4096-byte limit on the size of a cookie,although
support for 8192-byte cookies is becoming more common in the new
browser and client-device versions available today. √ Some users disable
their browser or client device’s ability to receive cookies, thereby
limiting the use of cookies. √ Cookies can be tampered and thus creating
a security hole. √ Cookies can expire thus leading to inconsistency. Below
is sample code of implementing cookies Request.Cookies.Add(New
HttpCookie(“name”, “user1”))
(I) What is Query String and What are benefits and Limitation of using
Query Strings?

A query string is information sent to the server appended to the end of a


page URL. Following are the benefits of using query string for state
management:- √ No server resources are required. The query string is
contained in the HTTP request for a specific URL.97 √ All browsers
support query strings. Following are limitations of query string :- √ 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. Below is a sample “Login” query string passed in URL
http://www.querystring.com/ login.asp?login=testing.This querystring
data can then be requested later by using
Request.QueryString(“login”).98 6.

OOPS

(C) What is Object Oriented Programming ?

It is a problem solving technique to develop software systems.It’s a


technique to think real world in terms of objects.Object maps the
software model to real world concept.These objects have
responsibilities and provide services to application or other objects. (B)
What’s a Class ?

A class describes all the attributes of objects , as well as the methods


that implement the behavior of member objects.Its a comprehensive
data type which represent a blue print of objects.It’s a template of
object.

(C) What’s a Object ?

It’s a basic unit of a system.An object is an entity that has attributes,


behavior, and identity. Objects are members of a class.Attributes and
behavior of an object are defined by the class definition.

(A) What’s the relation between Classes and Objects ?

They look very much same but are not same.Class is a definition ,
while object is a instance of the class created.Class is a blue print
while objects are actual objects existing in real world.Example we
have class CAR which has attributes and methods like
Speed,Brakes,Type of Car etc.Class CAR is just a prototype , now we
can create real time objects which can be used to provide
functionality . Example we can create a Maruti car object with 100
km speed and urgent brakes.

(B) What are different properties provided by Object-oriented systems


? Twist :- Can you explain different properties of Object Oriented
Systems?
Note:- Difference between abstraction and encapsulation is one of
the favorite interview question and quiet confusing as both the
terminology look alike.Best is if you can brainstorm with your friends
or do a little reading. Following are characteristic’s of Object
Oriented System’s :- * Who motivates you ?99

Abstraction

It allows complex real world to be represented in simplified


manner.Example color is abstracted to RGB.By just making the
combination of these three colors we can achieve any color in
world.It’s a model of real world or concept.

Encapsulation

The process of hiding all the internal details of an object from the
outside world.

Communication using messages

When application wants to achieve certain task it can only be done


using combination of objects.A single object can not do all the
task.Example if we want to make order processing form. We will use
Customer object , Order object , Product object and Payment object
to achieve this functionality.In short these objects should
communicate with each other.This is achieved when objects send
messages to each other.
Object lifetime

All objects have life time.Objects are created , initialized , necessary


functionalities are done and later the object is destroyed.Every
object have there own state and identity , which differ from instance
to instance.

Class hierarchies (Inheritance and aggregation) Twist :- What’s


difference between Association , Aggregation and Inheritance
relationships?

In object oriented world objects have relation and hierarchies in


between them.There are basically three kind of relationship in
Object Oriented world :- Association This is the simplest relationship
between objects.Example every customer has sales.So Customer
object and sales object have a association relation between them.
Aggregation This is also called as composition model.Example in
order to make a “Accounts” class it has use other objects example
“Voucher”,”Journal” and “Cash” objects.So accounts class is
aggregation of these three objects. *Which university are your
from ?100 Inheritance Hierarchy is used to define more specialized
classes based on a preexisting generalized class.Example we have
VEHICLE class and we can inherit this class make more specialized
class like CAR, which will add new attributes and use some existing
qualities of the parent class.Its shows more of a parent-child
relationship .This kind of hierarchy is called inheritance.
Polymorphism

When inheritance is used to extend a generalized class to a more


specialized class,it includes behavior of the top clas(Generalized
class).The inheriting class often implement a behavior that can be
somewhat different than the generalized class, but the name of the
behavior can be same.It is important that a given instance of an
object use the correct behavior, and the property of polymorphism
allows this to happen automatically.

You might also like