1. What is Asp.net?
Asp.net is a technology providing set
of specifications towards web based application development, this technology
comes with .net
Asp.net supports different types of
web application
· Normal Web Applications [webpage towards pc based browser].
· Mobile Web Applications [Webpage towards mobile device micro
browser]
· Web Services [Developing business logic towards business to
business implementation]
· AJAX Web Application [Developing web pages with AJAX
specifications, this will avoid complete page submission and reloading webpage]
2. What is page
directive?
Directive is an instruction to
server; it should be first statement with in webpage. Based on instruction
server will do the required processing.
3. Webpage creation
techniques supported by asp.net
Asp.net supports two techniques
· In page Technique
· Code behind Technique
In page Technique: when the logic part and
coding part placed within a single file .asp x is called in page technique this
is useful for migration projects.
Code behind Technique: placing design part into .asp x file and logic part into .cs or .vb file
is called code behind technique this makes development faster and provides
security for logic part.
4. Web server controls
These controls are very advanced
controls compare to html server controls, this will support extensibility. Web
server controls are classified into following things.
1.
Standard controls
2.
Validation controls
3.
Navigation controls
4.
Data controls
5.
Web parts controls
6.
Login controls
7.
AJAX extension controls
5. Page life
Cycle Events
Set of subprograms executed to words
each time of web page processing is called “page life cycle events”.
1.
Page Pre init: This will be executed before memory initialization for webpage
attaching theme, master page dynamically to web page is possible using pre init
event procedure.
2.
Page init: This
will be executed when memory is initialized for web page
3.
Page load: This will be executed when submitted data and controls are loaded.
Database connectivity, reading submitted data can be placed within page load.
4.
Page prerender: This will be executed before rendering HTML content for server side
control. Control behavior can be changed before producing client side control.
5.
Page unload: This will be executed once memory is released for webpage. Closing
database connection etc.
6. Validation control
ASP.net is providing set of controls
to perform validations; this will reduce manual coding for developer and makes
development faster.
ASP.net is providing 6 validation
controls
1.
Required Field Validator: It doesn’t allow textbox blank.
2.
Range validator: it will validate textbox data with a particular range.
3.
Compare Validator: It supports three types of validations
i>. Data type checking ii> .Validating textbox data with a
constant using relational operator.iii>.Comparing two textboxes using
relational operator
4.
Regular Expression Validator: It will validate textbox data against particular expression.
5.
Custom Validator: Developer should provide logic to perform custom validations; this
control supports client side validation and server side validation.
6.
Validation Summary : It will display all the error at one place
7. Style sheet
Style sheet is a set of
characteristics can be applied to html tags to extend functionality. Style
sheet can be classified into 3 types:
1.
Inline Style sheet
2.
Embedded Style sheet
3.
Cascading Style sheet
1. Inline
Style sheet: The style sheet applied to particular occurrence of tag is
called “Inline Style sheet”.
2. Embedded
Style sheet: The style sheet with in webpage is called “Embedded Style
sheet”.
3. Cascading
Style Sheet: The style sheet with in css file is called “Cascading style
sheet, this provides look & feel similar throughout website in different
WebPages & maintenance will be easier.
8. What is state
management?
Web server remembering information of
client is called “State management”. This can be implemented using following
techniques.
1.
Context
2.
Query String
3.
Cookies
4.
Session
5.
Application
6.
Cache
7.
View state
I.
Context: The user information variables can be maintained from one webpage to
another webpage using context when redirection is using Server. Transfer.
II.
Query String: The client information can be maintained from one webpage to another
webpage when redirection is using Response. Redirect.
III.
Cookies: cookie is a small amount of memory used by web server within client
system. The purpose is maintaining personal info of client with in client
system to reduce burden on server.
Cookies can be
classified into two types
1.
In memory cookie
2.
Persist ant cookie
1.
In memory cookie: The cookie placed within browser memory process in called “in memory
cookies”. .net providing http cookie class for sending or reading cookies.
Example:
Http cookie object = new Http cookies (“n”); (sending
cookies)
Object. Value=100;
Response. Append cookies (object);
Object=Request. Cookies [“n”]// Reading cookies
2.
Persist ant cookie: Cookie placed within hard disk
Memory of client system is called persist ant cookie
Http Cookie object= new Http Cookies (“n”);
Object. Value=100;
Object. Expires= Date time. Now. Add Days (2);
IV. Session Memory: when client makes a
first request, web server will allocate block of memory unique to client on
server system, this is called as session memory. The session memory will be
maintained by web server with the timeout of 20 minutes by default.
Example:
Session [“n”] =100 // it will place
variable into session memory
Remove (key)// it will remove
variable from session memory
Abandon () // It will close session
1.
What is session
tracking?
Session tracking is the concept of
web server identifying the session belonging to the client, this is implemented
using in memory cookie concept.
Web server will allocate unique ID to
each client called “Session ID”, this Session Id will be given to client
browser. Web server can generate 2120 unique session ID’s.
V. Application Memory.
When the website is started web
server will allocate a block of memory on server system common to all client,
this is called “Application Memory”. Application memory doesn’t have timeout,
it will be maintained throughout the website is running. Application object is
provided to access application memory from asp net page, this provides
following methods:
· Application[“n”]=100
· Remove(key)
· Remove all ()//it will remove all the variables from
application memory.
· Lock (): lock will lock application memory to particular
client request.
· Unlock (): unlock will release lock, this makes application
Memory available to other client.
VI. Caching:
Caching is the concept of storing
frequently used data into temporary memory for faster access. This is
considered as optimization technique to improve the performance of Web server.
VII. View State:
9. Grid view control
Grid View will display multiple
records in tabular format. These support different customizations like sorting,
paging, editing….
Date source property of grid view
requires memory location address where data is available. Data bind () method
of grid view will arrange records in a tabular format for displaying to client.
Grid view is providing different
types of fields for customization
· Bound Field: it will display normal text
<asp: bound field
header text=”Column heading” data field=”dataset table column
name”></asp: bound field>
· Template field: It is a container field for placing
web server control into grid view.
<Asp: template
field>
<Item template>
Place web server control
</item template>
</asp: template
field>
· Image filed: to place image into the grid view
· Hyperlink filed: To place hyperlink
into the grid view
· Command field: This will provide set of special
buttons
1. Select button: This button will
execute selected index changed () event of grid view and provides row selected
by user.
2. Edit Button, Cancel Button, Delete Button.
9. Data list control:
Data list is not provided with
predefined structure developer can customize required structure using
collection of templates provided with data list.
· Header template
· Item template
· Separator template
· Footer template
· Edit item template
The important template is Item
Template it will contain record structure.
10. What is bubbled
event?
Execution of parent control event
procedure towards child control action is called bubbled event.
11. What is the
difference between Repeater Vs Data list control
· Repeater comes with less number of templates [no edit item template].
Whereas Data list comes with more number of templates.
· Repeater doesn’t provide styles. Html tags to be used for formatting.
Data list provides style for formatting.
· Repeater supports only one record display in a row [no repeat column
property] Data list supports more than one record in a row.
· Repeater is light weight component, it consumes less memory resources and
processing will be faster over data list control.
· Data list and repeater doesn’t support sorting and paging.
12. List view control
This doesn’t provide build in
structure for presenting data; developer should customize structure using
templates.
This control is provided with Asp.net
3.5.
· Layout Template
· Item Template
· Alternating Item Template
· Edit Item Template.
· List view= Data list or repeater+ sorting and paging.
13. What is Dataset
serialization and De-serialization?
Serialization is the process of
converting object into stream [bytes arrangement].
De-serialization is the process of
constructing object using stream.
This is required in 2 cases
· Persisting object on to hard disk
· Transmission of object on network wire.
Persisting object requires explicit
serialization and de serialization.
Dataset supports xml based
serialization by providing following methods.
· Write XML
· Read XML
Write XML Method: For serialization
Write xml (“xml file path”, options)
Options:
Xmlwritemode.ignorescheme-It will perform serialization of only data without structure. This can be
used to download XML document to client system.
Xmlwritemode.Writeschema:-It will perform serialization of structure and data. This can be used
when the requirement is creating back dataset from xml content.
Xmlwritemode.diffgram:-It will perform serialization of old value and new values by maintaining
the status of each record. This is called state full serialization. This is
used for distributed technology like remoting and web services.
Read XML Methods: This will perform de-serialization
Readxml(“filepath”,options);
· Xmlreadmode.ignoresechema
· Xmlreadmode.readschema
· Xmlreadmode.diffgram
· Xmlreadmode.inferschema: It will apply structure based on type of data.
· Xmlreadmode.auto: It will apply one of the options based on content
present in XML Document.
14. Caching:-
Cashing is the concept of storing
frequently used data into temporary memory for faster access. This is
considered as optimization technique to improve the performance of Web Server.
When the webpage requires database communication for presenting data and
expected with more number of requests go will caching to reduce the processing
burden of the web server.
Asp.net supports 3 types of caching:
· Output Caching
· Fragment Caching
· Data Caching
Output Caching: Caching entire webpage output is called “Output Caching”. Output caching
directive can be used to apply output caching to webpage.
<% @ Output cache duration=”n
secs” varybyparam=”paramatername/name” varybycustom=”browser” verybyheader=
”accept-languag” location=”Server/Client/Server and
client/downstream/any/none”….%>
· Duration:-It will specify lifetime of cache
content
· Vary by par am:-Multiple cache content can
be maintained for webpage based on parameters values submitted by client.
· Vary by custom:-It supports maintaining
multiple cache content based on browser type.
· Vary by Header:-It supports maintaining
multiple cache content based on culture-type. This is required for
globalization website.
Fragment Caching: Portion of webpage applied with caching is called “Fragment Caching”.
Each portion is a web user control, so fragment caching is possible using web
user control.
Data Caching:-Caching memory variable like array, dataset, variables is called “Data
caching”. Data caching provides application level state, it is similar to
application memory state management.
15. What is the
difference between Application Memory and Data Caching?
· Application memory is not thread safe, where locking is required
explicitly. Data caching is thread safe, where locking will be applied
implicitly.
· Application memory will apply lock to all the variables. Data caching
will apply lock to the variable under processing.
· Application memory doesn’t support releasing variable memory when website
demands. Data caching will support releasing variables memory based on priority
when web site demands this is called “scavenging”
· Application memory doesn’t support expiry policies [defining life of
variable]. Data caching supports expiry policies.
o File based expire
o Time based expire
o SQL Cache dependency
· File based expire: The life time of cache
variable is based on time stamp of file or modification of file is called file
based expire.
· Time based expire: Life of cache variable
is based on particular time period is called “time based expiry”. This can be
classified into 2 types.
o
Absolute time expiry: lifetime of variable from storage time in cache is called absolute time
expiry.
o
Sliding time expiry: life time of cache variable from last access is called sliding time
expiry.
· SQL Cache Dependency: The life of cache
variable is based on database table manipulation is called “SQL cache
dependency”. This requires 3 steps.
o
Configuring SQL Server to monitor
table for manipulation using Example :- aspnet_regsql –U “sa” –P “
“ –d “inventory” -ed
o
Configuring website with cache
manager service to receive notifications from SQL Server.
o
Placing variable into cache with SQL
Cache Dependency.
15. Web user control:
The control created by developer is
called “user defined control”, this provides reusability and batter
maintenance. The control creation can be classified into 2 types
· Web user control
· Custom control
16. What is the
difference between web user control and custom control?
· Web user control is represented in the form of .ASCX [active server
control], it is not a complied code, the control cannot be placed on Tool box, and
it will be local to website.
· Custom control is represented in the form of DLL, it is complied code,
the control can be placed on Tool box, and it is global to set of websites.
· Web user control supports caching where as custom control doesn’t support
caching.
· Web user control doesn’t support scratch level control creation. Custom
control supports scratch level control creation[It is possible inheriting
control class or web control class]
· If the requirement is local to website or caching go with web user
control else custom control
17. What are session
state settings?
Session can be applied with 3 types
of settings
1.
Session mode setting
2.
Cookie less session
setting
3.
Optimization of session
setting
Session mode setting: Asp.net supports 3 types of sessions
I.
In proc Session
II.
State Server Session
III.
SQL Server Session
In Proc Session: The session with in website memory under worker process is called “in
proc session”.
In process session go with two
problems:
· No reliability: session will lost when website is restarted
· No solutions for web forming: Web forming is a
concept of running different websites on different web servers as a one unit.
In web farming, one session cannot be maintained for client with in process
session.
State Server Session: State server comes with .net installation as a service of operating
system. This implementation requires 2 steps.
· Start state server: start->run ---> services.msc ->ok then right
click & select start.
· Configuring the site to state server session web. Config…
<system.web>
<Session state Mode=”state server” state connection
string=”TCPIP=127.0.0.1:42424”/>
<system.web>
Note: state connection string requires IP address of system
in which state server is running and port number [42424] of state server.
· State server supports in memory storage i.e. temporary storage.
· Session will lost when state server is restarted and back up cannot be
maintained. The solution is SQL Server session state.
SQL Server Session
State: This provides persistent storage of sessions by
maintaining in the form of table, this provides more reliability and requires
more financial investment.
This requires 2 steps:
· Configuring SQL Server table
· Configuring Web site
· Configuring SQL Server: .net is providing
aspnet_regsql.exe utility to communicate with SQL Server for creating table
towards session state.
Example -> aspnet_regsql –U “sa”
–P “” –ssadd –sstype “c” –d “inventory”
It will create table with in
inventory database
-ssadd:--- adding session state table
-sstype:--“p” table will be created
within asp state database
“c” Table will be created
within specified database using “-d” option.
· Configuring website towards SQL Server session state:-
<system.web>
<session state mode=”SQL Server”
SQL connection string=”user id=sa; password=; database=inventory; data
source=syst” allow custom SQL Database=”true”/>
2. Cookie
less session: When client browser is disabled cookies, in this case
session will not be maintained for client. The solution is cookie less session.
Cookie less session is a concept of providing Session ID to client by appending
to URL; this is called “Munged URL”.
This requires setting in web.config
<session state cookieless=”true”
timeout=”30”/>
Note: cookie less session goes with
security problem, it is not recommended when sensitive data is stored in
session memory
3.
Optimization of Session: - Optimization of session is the concept of
making use session in a proper manner to improve performance of web server.
This can be applied at 2 levels
· Web site level
· Page level
Web site level: requires setting in
web.config
<session state
mode=”off/inproc……/>
Off->Sessions will not be created
for client, this will reduce lot of burden on web server.
Page level: Requires option with page
directive
<%@ page………..enable session state=”true[d]/false/read
only” %>
18. Asp.net Security
Asp.net provides security in the form
of 2 things
· Authentication and Authorization
· Membership
Authentication and Authorization:
Authentication is the process of getting the credentials of client like name,
password, security token etc.
Authorization is the process of
verifying credentials to provide access to resources.
Asp.net supports 3 types of
Authentications:
1.
Windows based
Authentication
2.
Forms based Authentication
3.
Passport Authentication.
1.
Windows based
Authentication: - Authenticating client based on
network level login parameters is called “windows based authentication”. The
security can be applied only to private website of organization.
Go to web.config
<authentication
mode=”Windows”/>
Then select web configuration file
<system.web>
<Authorization>
<allow users=”manager”/>
<deny user=”*”/>
</Authorization>
2.
Forms Based
Authentication: Authenticating client based on
custom login page verifying credentials with database is called “Forms based
authentication”.
This will be applicable
to private website and public website. Web server will provide security token
to client browser as an identity of authenticated client. This requires setting
in web.config.
Example:
<Authentication
mode=”Forms”>
<Forms name=”c1”
login url=”login.aspx”>
</Forms>
</Authentication>
<Authorization>
<Deny user=”?”/>
</Authrization>
Submit button_click
{
If (Textbox1.text==”kapil” &&
Textbox2.text==”Dev”)
System.web.security.FormsAuthentication.RedirectFromLoginPage
(Textbox1.text, C1.checked);
Else
Response. Write (“Invalid…..”);
RedirectFromLoginPage
() method will perform 2 things
· Redirecting client to requested page
· Security token will be given to client browser.
Passport
Authentication: Authenticating client based on
passport security token provided by passport.com site is called “passport
authentication”.
19. Web services
Web service is an application logic
managed by web server, accessible to different applications based on open
industry standards in platform independent way. Web services main target is
integrating different vendor’s software’s; this provides heterogeneous
application communication under heterogeneous platforms.
Web services complete designing is
based on XML with the standards provided by W3C.
Web Services provides following
standards:
· WSDL [Web Services Description Language]
· SOAP [Simple Object Access Protocol]
· HTTP
· UDDI [Universal Description Discovery Integration]
WSDL: - WSDL is an XML based language
for arranging description of Web Service methods.
SOAP [Simple Object Access Protocol]:
SOAP is a formatting protocol which provides a set of standards for arranging
request and response to provide communication between client application and
web service.
Structure of SOAP Message
· SOAP Header will contain address of destination and authentication info
if required.
· SOAP Body will contain method call info or result of method execution
· SOAP fault will contain error information if any.
What are the Web method
attribute class options?
· Description: This provides Web Service Method description to user.
· Enable Session: True/False[d] by default Session tracking is disabled for
web method it can be enabled by setting enable Session option
true………………………………………………..
[Web Method (enable session =true)
Public void m1 ()
{
}
· Message Name: Internally Web Method will be represented in the form of
XML format identified by message name. By default message name is same as Web
method name, this message name should be unique when web method is overloaded,
provide message name explicitly.
[Web method (message
name=”getprod1”)]
Public dataset get prods ()//method
overloading
{
}
[Web method (message
name=”getprod1”)]
Public dataset get prods (string
name)//method //overloading
{
}
· Cache duration: This will apply caching for web method
[Web Method (cache
duration=”300”)]
Public dataset get
prods ()
{ }
How to Securing Web
Service
Securing web service is providing
access to authorized users or securing transmission of data.
· IP Address and Domain name restriction
· SOAP Header Security
· SSL[Secured Socket Layer]
IP Address and Domain
name restriction: Providing access to web service
based on IP Address or domain name of client system is called “IP Address &
Domain name restriction Security.
Start-run-inetmgr-myservice.asmx
properties then select File Security Tab Remove Anonymous Access then move to
IP Address and Domain Name <- edit grant single computer give the IP
Address[127.0.0.5] and click ok. Web service will be accessible to system IP
Address 127.0.0.5.
SOAP Header Security: Providing access to web service method based on authentication is called
“SOAP Header Security”. The authentication information will be arranged within
SOAP Header of SOAP Message.
This requires two changes:
· Including SOAP Header class within web service file.
· Creating SOAP Header class object within client application to input
authentication information.
Example:
Go to service.cs
Public class AUTHINFO: Soap Header
{ Public
string username;
Public
string password;
}
Public class service: web service
{
Public AUTHINFO object=new AUTHINFO ();
[Web Method (), Soap Header (“object”)]
Public integer sum (integer a, integer b)
{
Object. Must Understood=true;
If (object. Username==”KAPIL” &&
object. Password==”dev”)
{
Object. Did
understand=true; //It is informing soap that authentication information is
valid, SOAP will prepare soap message with result.
Return (a + b);
}
Else
{
Object. Did
understand=false; //authentication information is not valid.
Return (0);
}
}
SSL (Secure Socket
Layer): SSL provides secure communication between client and
web server, this is strongly recommended when sensitive data is transmitted
between browser and web server. The secure communication is possible through
encryption and decryption.
UDDI Registry [Universal
Description Discovery Integration]
UDDI registry acts like search engine
for web services this provides technical information of web services free web
services and business oriented web services.
Example:
What Web Services
cannot do?
· Attaching file to SOAP Message is not possible
· Message Level security is not supported
· Web services cannot be hosted outside the web server
· Messaging is not supported by web services.
WCF [Windows
Communication Foundation]
WCF is a very rich distributed
technology provided with .net 3.0 WCF major concentrations is unifying
different existing technologies under its roof. WCF is extensible framework and
comes with built in infrastructure. This makes developer, administrator and
architect job easier.
WCF is completely based on ABC analysis
Address: - It will specify where WCF service is available example:
net.tcp://server name: port number
/service name
WCF Service can be given with more than
one address.
Binding: It will specify how WCF service provides communication
This will specify different encoding
formats
Net Tcp Binding…………….Remoting
Basic Http Binding……………Web Services
WS Http Binding………………. WS default WCF
service supports multiple binding.
Contract: It will specify what WCF service provides to client application [which
interface, method exposing to client]
These 3 combine can be called as end point.
WCF Service supports hosting outside IIS.
.net is providing an assembly towards
WCF Service implementation.
System.ServiceModel.dll
|
System. Service Model Namespace
|
Classes
|
Service Contract Attribute
Class
Operation Contract Attribute
Class
Service Host Class
Interface can be exposed to client by
declaring as Service Contract interface
Service Contract interface methods can
be exposed to client by declaring as Operation
Contract methods. It is similar to Web Method in web service.
Service Host class is
required to host WCF Service outside IIS.
WCF Implementation
requires 2 steps:
1. Creating
Server application for hosting WCF Service this requires 3 things
· Creating
Service Contract Interface
· Creating WCF
Service Class implementing Service Contract interface.
· Hosting WCF
Service Class. If it is hosted with IIS, Manual coding is not required outside
IIS requires manual coding.
2. Creating
Client application to communicate with WCF Service. This requires generating
proxy to communicate with WCF Service.
What are the binding
supported by WCF.
·
MexTcpBinding will expose types of WCF Service [Exposing
Meta data]
·
NetTcpBinding provides binary encoding , it is similar
to remoting
·
Basic Http Binding provides XML encoding; it is
similar to web Service.
What is .svc file in WCF?
Answer:
.svc file is a text file. This file is similar to ours .asmx file in web services.
This file contains the details required for WCF service to run it successfully.
This file contains following details:
1. Language (C# / VB)
2. Name of the Service
3. Where the service code resides
Example of .svc file
<%@ ServiceHost Language="C#/VB" Debug="true/false" CodeBehind="Service code files path" Service="ServiceName"
.svc file is a text file. This file is similar to ours .asmx file in web services.
This file contains the details required for WCF service to run it successfully.
This file contains following details:
1. Language (C# / VB)
2. Name of the Service
3. Where the service code resides
Example of .svc file
<%@ ServiceHost Language="C#/VB" Debug="true/false" CodeBehind="Service code files path" Service="ServiceName"
No comments:
Post a Comment