46754 asp net notes

Upload: goutami-perala

Post on 06-Apr-2018

224 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 46754 ASP Net Notes

    1/15

    ARCHITECTURE OF ASP.NET

    ARCHITECTURE OF ASP.NET

    HTTPREQUEST

    inet_info.exe

    Machine.config

    Web.config

    HTTPRESPONSE

    Aspnet_isapi.dll

    Asp.dll

    Process Req

    Web Server ASP.net Runtime Env

    Aspnet_wp.exe

    App Domain

    HTTP Handlers

    (.aspx)

    (.asp)

    Inet_info.exe identifies the request and submits the request to the aspnet_isapi.dll.Aspnet_isapi.dll is a script engine which process the .aspx pageThen the script engine will submit the request to the ASP.NET runtime env.After verifying all the security issues of both machine.config and web.config then anAppDomain will be defined for the request and after processing the request the responsewill be given to the client as HTTP response.Machine.Config it is used to maintain the complete configuration details of all the webapplications registered on to the web server of ASP.netWeb.Config It is used to maintain the config details about a single web application.Where configuration details includes security,database connectivity,statemanagement,trace details of the web application,,authentication and authorization of theapplications and globalizationsAppDomain:All windows appns run inside a process and these process own resourcessuch as memory and kernel objects and the threads execute code loaded into aprocess.Process are protected from each other by the OS. All these appns are run onhigh isolation mode to work safely.The disadvantage of this is memory resources areblocked.So to achieve this in a single process all the applications should be made to runwhich is good to an extent but the draw back is if one crashes all other are effected. So in.net the code verification feature takes care that the code is safe to run.so asp.net each application runs its own application domain and therefore it is protectedfrom other asp.net applications on the same machine so it ignores the process isolation

    specified on IIS.HTTPHandlers:ASP.net builds upon a extensible architecture known as HTTPruntime.This is responsible for handling the requests and sending the response.It is uptoan individual handlers such as asp.net or web service to implement the work done on arequest.IIS supports a low level API known as ISAPI. ASP.net implements a similarconcept with HTTP handlers.A request is assigned to ASP.net from IIS then ASP.netexamines entries in the section based on the extension of the request todetermine which handler the request should be send to.

  • 8/3/2019 46754 ASP Net Notes

    2/15

    Features of asp.netASPX,ASP

    Up gradation of ASP to ASPX is not required it supports side by side executionand hence a request can be given from ASP to ASPX and vice versa.

    Simplified Programming ModelASP.Net is a technology which can be implemented using any dot net languagesuch as VB.net,C# etc and hence there is no requirement of HTML,JavaScript orVBScript to implement ASP.NET

    Simplified deploymentASP.Net supports setup and deployment and hence the web app can be defined

    with a web set up project which can be easily deployed on to the web server.Where as for ASP CUTE FTP is used for deploying manually we have to upload.

    Better PerformanceAs the ASPX pages are complier based the performance of the web applicationwill be faster then the ASP pages (as they are interpreter based)

    CachingIt is a process of maintaining the result or output of a web page temporarily forsome period of time .ASP supports Client Side caching where as ASP.Netsupports both client side and server side.

    Security

    In ASP security is done by IIS or writing the code manually. Where as ASP.Netis defined with built in security features such as windows authentication Forms Authentication Passport Authentication Custom Authentication

    More powerful data accessASP.net supports ADO and ADO.Net as its database connectivity model whichwill be implemented using the most Powerful OOPS languages like VB.Net andC# and hence the database access using ASPX pages will be very powerful.

    Web servicesIt is a code which will be published on the web which can be used by anyapplications written using any language for an platform or device.

    Better session ManagementSession Management in ASP.Net can be maintained using the database and aswell cookieless sessions are also supported.It also supports enabling anddisabling of session info within a web application.

    Simplified Form ValidationsASP.Net provides validation controls using which any type of client sidevalidations are performed without writing any code.

    A web page is in 2 parts1} Designing part (HTML Content,Flash,Dreamweaver etc)2} logic Part (sub programs and event procedures and it has also your databaseinteraction)ASP.Net supports 2 techniques for creating web page

    1) In Page Techniquewhen you place design part code and logic part code with in a single f ile called asASPX then it is called as inPage Technique.2) Code Behind Technique

    when design part code is represented with in ASPX file and logic part code isrepresented with in dll file then it is called as code behind technique.ASP Supports only In Page technique.DLL file is not a readable file so it is secured.

  • 8/3/2019 46754 ASP Net Notes

    3/15

    Difference Between VB 6.0 & VB.NET

    1) It is an object based programming2)Variables or member declarationsare not mandatory3)Uses Unstructured method forhandling exceptions

    4) Uses DAO, RDO, ADO objectmodels for database connectivity5)Uses Data projects as its defaultreporting tool

    1) It is an object oriented programming2)Here its mandatory

    3) Uses Unstructured / Structured methodsfor handling exception

    4) supports ADO and ADO.NET models

    5) uses crystal reports

    6)Uses COM for languageinteroperability7)Does not support multi threading8)Uses DCOM to support distributedtechnology9) Supports web tech.,client sideappns or server side appns can bedesigned using VB

    6) Uses .net assembly for languageinteroperability7)Does support multithreading8)Uses .net remoting to support distributedtech.9)It does not support web technology.Note VB.net cant be used to design ClientSide / Server side appns but it can used as

    an implementing Lang for asp.netDifferences between C#.net & VB.net

    W.R.T C#.NET VB.NET

    DATA TYPES 1.Unsigned Data Types2.Strongly Typed Lang.

    1.No Unsigned Data Types2.It is not strongly typed

    OOPS Concept More concepts in C#u have interfaces, abstraction,indexes

    Less Concepts here.No indexes in Vb.net and it haslimitations wrt interface

    Memory Manag. Garbage Collector.

    Automatic releasing ofresources is available.It Boosts the performance.

    Garbage collector,

    destructor,dispose.Automatic releasingof resources is not available.You have toexplicitly use dispose method

    OperatorOverloading

    Is available in C# Is not available in VB.Net

    Pointers Is available in C# Is not available in VB.Net

    Auto XMLDocument.

    Is available in C# Is not available in VB.Net

    Page Life Cycle EventsPage_Init

    This is fired when the page is initializedPage_Load

    This is fired when the page is loadedThe difference between Page_Init and Page_load is that the controls are guaranteed tobe fully loaded in the Page_load.The controls are accessible in the Page_Init event,but

  • 8/3/2019 46754 ASP Net Notes

    4/15

    the ViewState is not loaded,so controls will have their default values,rather than anyvalues set during the postback.Control_Event

    This is fried if a control triggered the page to be reloaded (such as a button)Page_unload

    This is fired when the page is unloaded from the memory

    Types of Controls in ASP.NetHTML SERVER

    SYNTAX

    WEBSERVER CONTROLS

    StandardControlslabelTextboxButtonLink ButtonImage ButtonCalendarAdRotatorPanelPlace HolderTableLiteral ControlRadio ButtonCheck BoxXML

    List Controls Radio ButtonList Check Box

    ListDropdownListList Box

    ValidationControlsRequiredfield ValidatorRangeValidatorCompareValidatorRegularExpressionValidatorCustomValidatorValidationSummary

    DataboundControlsData GridData ListRepeater

    MiscControls

    CrystalReportViewercontrol

    Common Syntax for any web server controlTo close syntax is / .

    In order to set or get the value from any standard control text property should be used.Eg:

    Calendar ControlUsage: It is used to place the calendar on the webform

    Note: Place the calendar control and right click on it and select autoformat toprovide a better look and feel for the control Calendar control can be considered as a collection of table cells Where every table cell will maintain the information about the days as a calendar day in

    the format of a link button control When ever the calendar days has to be customized based on the requirement of the user

    DAYRENDER event should be used. Every event handler in the dot net tech will accept two arguments 1st one being object

    and the 2nd one is eventArguements I.e. DayRender(Object,eventArguements)

  • 8/3/2019 46754 ASP Net Notes

    5/15

    Event Arguments of DayRender event will provide e.cell -> to refer table cell e.day -> to refer calendar day

    In order to add a string value as a control to any other control Literal Control Should beused.

    ADO.NET CONNECTION ORIENTED MODEL DISCONNECTED ORIENTED MODEL

    CONNECTION ORIENTED MODEL Whenever an application uses the connection oriented model to interact with the db then

    the connectivity between the application and the database has to be maintained always. Whenever an user executes any statement other than a select then command object can

    be binded directly to the application If the user executes a select statement then dataReader is used to bind the result to the

    application.Disconnected Oriented Model

    When the user interacting with the db using this model then while performing themanipulations or navigations on the data connectivity between the application and thedatabase is not required

    Note: When ever the data is been updated on to the database then the connectivity is required inthe disconnected model.

    DISCONNECTED MODEL

    DatabaseDataSetApplication

    Data Adapter Connection

    Data View

    Data Providers

    This is available in

    client system

    Disconnected Model

    Connection it is used to establish the physical

    connection between the application and the database

    DataAdapterit is a collection of commands which acts

    like a bridge between the datastore and the dataset.

    Commands in DataAdapter

    Select Command

    Table Mappings

    Insert Command

    Update Command

    Delete Command

    DataAdapter Collection of all these commandsis DataAdapter

    Fill(Dataset Name[,DataMember])

    Update(Dataset Name[,DataMember]

  • 8/3/2019 46754 ASP Net Notes

    6/15

    DataAdapter DataAdapter can always be binded to a single table at a time. Whenever the dataAdapter is used then implicit opening and closing of connection of

    closing object will take place. If the dataAdapter is defined using a tool or a control then all the commands for the

    adapter will be defined implicitly provided the base table with a primary key. If the base table is not defined with a primary key then the commands relevant for update

    command and Delete command will not be defined.Fill Method

    It is used to fill the data retrieved by the select command of DataAdapter to the dataset.Update Method

    It is used to update the dataAdapter with the data present in the dataMember of thedataSet. In other words used to the update the database.

    DataSet It is an in memory representation of the data in the format of XML at the client system. Points to remember about DataSet:

    It contains any no of datatables which may belong to the same or differentdatabases also.

    If any manipulation are performed on the database it will not be reflected on tothe database.

    Dataset is also considered as a collection of datatables where a datatable can beconsidered as a DataMember.

    Dataset will not be aware of from where the data is coming from and where thedata will be passed from it.

    Dataset supports establishing the relationship between the datatables present inthe dataset where the datatables might belong to different databases also.

    DataSet is of 2 types Typed DataSet when ever the dataset is defined with the support of XML

    schema definitions then it is said to be typed dataSet. UnTyped DataSet if the dataset is defined without the XML Schema Definition

    then it is said to be UnTyped DataSet.DataView

    It is logical representation of the data present in the datamember of dataSet.

    Usage It is used to sort the data,filter the data or if the data has to be projected in thepagewise then the dataView should be used.

    Command It is used to provide the source for executing the statement I.e it used to specify the

    command to be executed.Data Reader

    It is a forward and read only record set which maintains the data retrieved by the selectstatement.

    ADO.NET

    DISCONNECTED MODEL CONNECTION ORIENTED MODEL

    CONNECTION

    DATA ADAPTER

    DATA SET

    DATA VIEW

    UI

    CONNECTION

    COMMAND

    DATA READER

    UI

    Used if the data has to be filtered,

    sorted or if the data has to be projected

    in page-wise

    Used if the statement is

    select statement

  • 8/3/2019 46754 ASP Net Notes

    7/15

    ADO.NET

    SQL-SERVER ORACLE OleDB ProvidersODBC

    providers

    SQL Connection

    SQL Command

    SQL Datareader

    SQL DataAdapter

    Oracle Connection

    Oracle Command

    Oracle DataReader

    Oracle DataAdapter

    OleDB Connection

    OleDB Command

    OleDB Data Provider

    OleDB DataAdapter

    ODBC Connection

    ODBC Command

    ODBC DataProvider

    ODBC DataAdapter

    System.data.SqlClient System.data.OracleClient System.data.Oledb System.data.ODBC

    Syntax to define the Object Dim objectName as new xxxConnection(ProviderInfo) where xx can be either

    SQL,Oracle,Oledb or ODBC Provider Info

    To connect to MS-Access 2000 above versions Provider=microsoft.jet.oledb.4;datasource=databaseName.mdb

    To connect to SQL-Server db Provider=sqloledb.1;userid=sa;password=;database=database

    name;datasource=servername Note if SQL Connection is used then provider=providername is not

    required.

    To Connect to ORACLE Provider = oracleoledb.oracle;userid=scott;pwd=tiger;datasource =

    servername OR Provider = msdaora.1;. Note if oracle connection is used then provider= provider name is not

    required.

    To define Command Object Dim objectName as new xxxCommand([SQL Statement,connection

    object/Connection String]) To define DataReader

    Dim objectName as xxxDataReader

    To define DataAdapter Dim objectName as xxxDataAdapter(Select Statement,) When ever the DataAdapter is defined using the above syntax then only the

    command relevant for the SelectCommand will be defined and in order to use theabove commands they have to be build explicitly.

    To define DataSet Dim objectName as new DataSet()

    To define DataView Dim objectName as new DataView(datasetName.DataMemberName)

  • 8/3/2019 46754 ASP Net Notes

    8/15

    Security in ASP.NET Asp.net provides various authentication methods to achieve security. They are:

    Forms Authentication Windows Authentication Passport Authentication Custom Authentication

    FORMS Authentication It is used to authenticate the user credentials for Internet and Intranet applications. It is used to specify the authentication mode to be used by the ASP.Net web application,

    to specify the login page information and to specify the format of the password to be usedfor providing additional security and also it acts like a database which maintains the usercredentials information.

    Syntax to set the authentication

    __________________________ any no of user information

    Authorization It is used to allow or deny the users from accessing the webforms present in the web

    application.

    Note: the tags and the attributes present in the web.config is a case sensitive contents. In order to support Forms Authentication in ASP.Net the Dot Net Framework provides a

    base class library called as System.web.security.Formsauthentication

    Methods to support Forms Authentication Authenticate :It is used to authenticate if the provided information belongs to a valid

    user credentials or not.It returns True if user info is valid else returns false. Syntax authenticate(username,password) RedirectFromLoginPage It is used to redirect to the requested webform from the login

    page if the provided user credentials belongs to a valid user. Syntax :- redirectFromLoginPage(username,booleanvalue) If specified TRUE then the user info will be maintained as a permanent HTTP Cookie at

    the client system and if FALSE is specified then user info will be maintained temporarilytill the browser is closed.

    HashPasswordForStoringInConfigFileit is used to encrypt the data using either SHA1or md5 hash algorithms.

    Syntax HashPasswordForStoringInConfigFile

    (original Text,md5/sha1) SignOut It is used to clear the session of the user which has been set the application User.identity.name returns the name of the user who has currently logged in.

    Windows Authentication It is used to authenticate the user information based on the users registered on the

    network. Note it is used to validate the users on the intranet environment. In web.config file

  • 8/3/2019 46754 ASP Net Notes

    9/15

    Whenever the user who has been currently logged in is present in the allow users list

    then all the webforms can be accessed directly present in the web application.Elseimplicilty the webserver will project a dialog box to provide the user credentials and allowthe user to access the webforms provided the information belongs to a valid usercredentials.

    Types of Windows Authentication Basic Authentication if used as authentication type then the user credentials will be

    passed across the n/w in cleartext Format. DigestAuthentication it is a special authentication type used to authenticate the

    Domain server users. Note if the OS is not a domain server then the Digest authentication type will be

    disabled in that system NTLM authentication it is a default authentication type used by the windows

    authentication where NTLM stands for Integrated Windows Authentication

    Steps to set the authentication Type

    Start > RUN > inetmgr Right click on default web site and select properties Click on Directory Security tab Click on the Edit button present in the anonymous access and authentication control Check on the different authentication types to be used To know the domain name of the system

    [ In command prompt ] C:\host Name

    This gives the domain name

    Passport Authentication If the same user credentials has to be maintained across multiple websites then passport

    authentication can be used.

    To achieve this Install Microsoft Passport SDK In web.config file

    Custom Authentication

    It is used to Validate the user credentials as per the requirement of the application.

    STATE MANAGEMENT IN ASP.NET It is used to maintain the state of the user across multiple pages.

    { OR } Web server maintaining client information with out any connectivity is called asstate management .This can be implemented in various ways

    1.View State [ Hidden field ]2. Page Submission3.Cookies4.Session5.Query String6.Application7. Cache

  • 8/3/2019 46754 ASP Net Notes

    10/15

    View State It is the concept of persisting controls properties between requests under post back

    implementation. The view state will be implemented based on hidden field. The main advantage of view state will be 2 things There is no programming required from the developer so less burden on the developer. The memory will not be allocated in the client system nor at in the webserver system.It

    will be maintained as the part of the web page itself. The problem with a view state is there will be more amount of data transfer between

    client and web server. The view state can be controlled at the 3 levels

    1 } Control Level Note : when it comes to sensitive data it is not recommended to implement view statethe sensitive data can be password,credit card no, etc.

    When you go with password type textbox the view state will not be applicable implicitly. 2} Page Level

    3 }Application Level

    It requires web config

    It will be applicable to all the web pages

    COOKIES It is used to maintain the server side information at the client system. { OR } A cookie can

    be defined as a small amount of memory used by the web server on the client system.Usage : The main purpose of cookies will be storing perosonal information of theclient,it can be username,pwd,no of visits,session id.

    Cookies can be of 2 types:- Client Side Cookies If the cookie information is set using Javascript / VbScript within

    an HTML page then it is said to be a client Side Cookies. Server Side CookiesIf the cookie information is set using server side technology then

    it is said to be server side cookies.They are of 2 types:1] Persistant Cookies ( Permanent Cookies )

    2] nonPersistant Cookies ( Temporary Cookies ) 1] Persistant Cookies ( Permanent Cookies )

    When the cookie is stored on to the hard disk memory then it is called aspersistant cookie.

    When you provide expires than the cookie will be considered as persistent. 2] nonPersistant Cookies ( Temporary Cookies )

    When the cookie is stored with in the process memory of the browser then it iscalled temporary cookies.

    Syntax To set the cookies information

    Response.cookies(cookie name).value = value To get or read the value from a cookie

    variable =

    request.cookies(cookie name).value

    Points to remember about cookies Cookies information will be always be stored at the client system only. Cookies information are browser dependent ie the values of the cookies set by one

    browser cant be read by other browser. If the cookie information is set by IE then that info. Will be maintained in the memory of

    the browser itself. If the cookie information is set by Netscape Navigator then then information will be

    maintained in Cookies.txt file.

  • 8/3/2019 46754 ASP Net Notes

    11/15

    There is no security for cookies information. Browsers has a capability to disable the usage of cookies within it. Note if the browser disables the cookies in it and if any request for a web form which

    contains the usage of cookies then the request will not function properly. User can change cookie content (or) user can delete Text file. The browser will support 20 cookies towards a single website . If we add 21st cookie then

    automatically the first cookie will be deleted. A cookie can represent maximum of 4kb of data. To bind the cookie information to a specific domain

    response.cookies(cookie name).Domain = DomainName To allow the different paths of the same domain to access the cookie information

    response.cookies(cookie name).path = /path. notethe default expiration time for the cookies is 30 min.

    To set the expiration time for the cookie info response.cookies(cookie name).expires = dateTime

    To secure the cookie information response.cookies(cookie Name).secure = booleanValue

    SessionWhen client makes a first request to the application,ASP.net runtime will create a block of

    memory to the client in the web server machine.This Block of memory is called as sessionmemory.This memory will be unique to the client with the Time Out of 20 min by default.Heretimeout indicates from the last access of client request not from creation of cookies.Cookie canrepresent only plain text not an object but session memory has an object.Differences between Session & Cookies

    Session Cookies

    It will be maintained in the webserver system.So it is called asserver side management

    It will be maintained in the clientsystem. So it is called as clientside state management.

    Session can represent objects Cookie can represent plain text

    More security for data Less security for data.

    Accessing will be slow Accessing would be faster.

    Limitations of sessions in ASPIn ASP client info is maintained by the server using its sessionID irrespective of sessionobject usage.Sessions in ASP are always cookies based.Enabling and disabling of sessions are not supported in ASP

    Sessions in ASP.NetSessions in ASP.net can beCookies Based ( Default )CookielessIt can be stored in database also (SQL Server)

    Syntax To get session InfoSession(variable) = value

    To Read / Get valueVariable = session(variable)

    Note:If the value assigned to the session variable is a character data then the info will bemaintained in the contents collection of the session objectIf the value assigned to the session variable is an object then that information will bemaintained in the static object collection of session object.

  • 8/3/2019 46754 ASP Net Notes

    12/15

    By default session state for the application will be true and hence the contents of thesession object can be used.In order to disable the session object usage in the web form then enable session stateattribute of the page directive should be set as false.In the page directive I.e go to the HTML view and in that page directive at the start of thepage make the enable session state as = false.Syntax

    Session ObjectSession Object this object can be used to access session memory from asp.net webpage.The following are the methods 1. Add(key,value) where key String and value object2.Remove(key)3.Abandon() to close the session4.SessionId5.TimeOut

    Points to remember about SessionThe default session timeout is 20mins

    To set the session timeoutsession.timeout = minutes ( specify the min){OR}In web.config we have tag available for sessionNote : the default sessionstate uses cookies for maintaining the data or info.To define a session as cookie-less then in web.config:note: once the sessionstate is set to cookieless then the sessionInfo or the sessionIDwill be appended to the URL for each and every webform present in the web application.In order to retrieve the sessionID of the clientsession.sessionID should be used.In order to maintain the session info. On the SQL server database then in web.config:

    In order to clear the session variable present in the session object contents collectionthensession.contents.remove(sessionvariable) In order to clear all the items present in the contents collection thensession.contents.removeall() should be used.In order to kill the session of the user then session.abandon() method should be used. To disable the session information for a specific webform thenenablesessionstate=false should be set for the page.

    Application

    It is used to maintain the state of all the users accessing the web applications. When the first client,first request comes to the application web server will allocate a blockof memory this is called as application memory.

    The application memory will not have any life time. Application object can be used to access application memory from asp.net web page Application object consists the following methods

    1} Add (key,value) {or} Application(var) = value 2} Remove(key)3} lock()

  • 8/3/2019 46754 ASP Net Notes

    13/15

    4} unLock()note the lock and unlock are not available in session,but available in application .

    To set:Application (variable) = value

    To read:variable = application(variable)

    ProblemIf the application object is not maintained properly then it will result in DataInconsistency.

    When ever the application variables are used in the webform then it is mandatory to Lockthe application contents.

    To do: Application.Lock() If application.lock() method is encountered while processing the webform then all the

    other requests which uses the application contents will not be blocked till the webformprocessing is completed.

    Lock is used to allow only one client at a particular time. Each client requests to the webserver is considered as thread.webserver will allocate

    equal processor time to all the threads.In this aspect more then one thread canmanipulate application memory data,this may lead to improper result to avoid this it isrecommended for synchronisation of threads.

    Synchronisation is nothing but allowing user one at a particular time.

    The synchronisation of threads can be implemented using lock and unlock methods.

    Global.asax Its a collection of events where the code written in those events will be executed

    implicitly whenever the relevant event takes place. In order to work with the application and the session objects and to handle the events in a

    proper manner global.asax file should be used. Application_Start the code written in this event will be executed only once whenever

    the application has been encountered with the first request Session_Start the code written in this event will be executed when ever a new session

    for the user starts. Application_BeginRequest the code written in this event will be fired when ever any

    webform present in the webapplication is loaded.

    Application_Authenticate the code written in this event will be executed when even theauthentication takes place.

    Application_error the code written in this event will be executed when ever any error orexceptions occurs at webforms present in the web application.Note in order to get the last error which has been generated on the webformserver.getLastError() should be used.

    Session_End the code written in this event will be executed whenever the session ofthe user ends

    Application_End the code written in this event will be executed whenever the webapplication is closed.

    Caching It is used to maintain the result of the webform temporarily for a specific period of time.

    ASP supports client side caching. Where as ASP.net supports both client side caching and server side caching.

  • 8/3/2019 46754 ASP Net Notes

    14/15

    Client Side Caching

    If the cache page is maintained at the

    client side it is said client side caching.

    C1

    C2

    C3

    Cache pageModem ISP

    Gateway

    Web serverServer

    Proxy

    Server

    To Set this :

    Response.cachecontrol = public Advantage : only the people who are connected in the network they will be getting the

    page faster.

    Server Side Caching then it is said to be server side caching. Points to remember Caching should be used if and only if the following properties are satisfied

    1} The contents of the webform should not be modified at least for a specific period oftime.2} The no of clicks for the webform present in the web application should be more.

    Types Server side caching

    1~~~> Page Output Cache 2 ~~~> Page Fragmentation (Partial) Cache 3 ~~~> Data Cache.

    Page Output cachewhen ever the complete result of the webform or the o/p of the webform is maintained as acache page at the webserver then it is said to be a page-output cache. To Set

    VaryByParam it is used to set an individual cache page for every distinct valueassigned for the control or the variable assigned to the varybyparam.{example 1}

    Page Fragmentation Cache It is used to maintain only a partial page contents as acache contents on the web server

    To achieve this Page Fragmentation Define a web custom control Set the cache for the custom control use the web custom control on the web form.

    Web User Control Web User Control It is used to design a web control which can be used by an

    webforms of ASP.net

  • 8/3/2019 46754 ASP Net Notes

    15/15

    To design Project Add web user control To use the web user control on the web form 1st method

    select the name of the web user control file in the solution explorer and then drag dropthat file on to the web form.

    2nd method 1} register the web user control as a tag prefix in the webform:for eg :2} place the web user control as a normal control on the webform

    Data Cache It is used to maintain the data present in an object as a cache information ,where the

    object can be dataset,datview or datareader. Note: once the data is been set as a cache then if the data is modified or manipulated

    at the database level there wont be any reflection at the data present in the cache.

    Tracing

    It is used to trace the flow of the application. It is of 2 types Application level tracing If this is used then for all the webforms present in the web

    application the trace details or information will be provided. Page level tracing if used then only specific web form the trace details will be set. Note if the application level and page level tracing information is set then the

    preference will be given to the page level tracing only. To set application level tracing

    in web.config Methods to support tracing

    Trace.write It is used to write the data on to the trace information. Trace.warn it is used to write the data on to the trace information using red as its fore

    color such that the information will be highlighted at the trace info section.

    To set page level trace info in page directive tag :