6
MC0081 – .(DOT) Net Technologies ( Book ID: B0974) Set-1 1. Describe the following: Importance of ADO.Net Data Access Scenarios Disconnected Architectures Ans:1 Importance of ADO.Net: The ADO.NET has been developed to enhance he creation of powerful and scalable web applications, by working with data in a disconnected way under the . Net framework ’s stateless distributed web model. It has been specifically designed to operate in a 3-tier environment. As the ADO.NEToperates in a disconnected way, no longer remaining connected to the dataserver while performing positional updates, there is a far great scope for data manipulation. ADO.NET was first introduced in version 1.0 of the .NET framework, that provided an extensive array of features to handle live data in a connected mode or data that is disconnected from its underlying data store. Today with the explosion of the Internet as a means of data communication , a new data technology is required to make data accessible and updateable in a disconnected architecture . Data Access Scenarios: I. The most popular data access scenario in the Internet is the one in which a user must locate a collection of data and iterate through this data a single time. When a request for data from a Web page that you have created is MC0081 – .(DOT) Net Technologies Roll No. XXXXXXXXX received, you can simply fill a table with data from a data store. In this case, you go to the data store, grab the data that you want, send the data across the wire, and then populate the table. In this scenario the goal is to get the data as fast as possible. II. The second way to work with data in a disconnected architecture is to grab a collection of data and use this data separately from the data store itself. This data could be either on the client machine or the server machine. Even though the data is disconnected, you want the ability to keep the data (with all of its tables and relations in place) on the client side. ADO.NET is a reflection of the data store itself, with tables, columns, rows, and relations all in place. When completed working on the client side copy of the data, the changes done to the data could be made persistent back into the data store from where the data was retrieved. The technology that enables the user or the programmer to perform this task is the DataSet. Like their counterparts in the unmanaged world, managed applications can and often do utilize industrial-strength databases such as Microsoft SQL Server and Oracle 8i. That’s why Microsoft created ADO.NET, an elegant, easy-to-use database API for managed applications. ADO.NET is exposed as a set of classes in the .NET Framework class library’s System. Data namespace and its descendants. Unlike ADO and OLE DB, its immediate predecessors, ADO.NET was designed from the outset to work in the connectionless world of the Web. It also integrates effortlessly with XML, bridging the gap between relational data and XML and simplifying the task of moving back and forth between them. Disconnected Architectures: The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called

MC0081

Embed Size (px)

Citation preview

Page 1: MC0081

MC0081 – .(DOT) Net Technologies ( Book ID: B0974)

Set-1

1. Describe the following: Importance of ADO.Net Data Access Scenarios Disconnected Architectures

Ans:1 Importance of ADO.Net: The ADO.NET has been developed to enhance he creation of powerful

and scalable web applications, by working with data in a disconnected way under the .Net framework’s stateless distributed web model. It has been specifically designed to operate in a 3-tier environment. As the ADO.NEToperates in a disconnected way, no longer remaining connected to the dataserver while performing positional updates, there is a far great scope for data manipulation. ADO.NET was first introduced in version 1.0 of the .NET framework, that provided an extensive array of features to handle live data in a connected mode or data that is disconnected from its underlying data store. Today with the explosion of the Internet as a means of data communication, a new data technology is required to make data accessible andupdateable in a disconnected architecture.

Data Access Scenarios: I. The most popular data access scenario in the Internet is the one in which a user must locate a collection of data and iterate through this data a single time. When a request for data from a Web page that you have created is MC0081 – .(DOT) Net Technologies Roll No. XXXXXXXXX received, you can simply fill a table with data from a data store. In this case, you go to the data store, grab the data that you want, send the data across the wire, and then populate the table. In this scenario the goal is to get the data as fast as possible.II. The second way to work with data in a disconnected architecture is to grab a collection of data and use this data separately from the data store itself. This data could be either on the client machine or the server machine. Even though the data is disconnected, you want the ability to keep the data (with all of its tables and relations in place) on the client side. ADO.NET is a reflection of the data store itself, with tables, columns, rows, and relations all in place. When completed working on the clientside copy of the data, the changes done to the data could be made persistent back into the data store from where the data was retrieved. The technology that enables the user or the programmer to perform this task is the DataSet. Like their counterparts in the unmanaged world, managed applications can and often do utilize industrial-strength databases such as Microsoft SQLServer and Oracle 8i. That’s why Microsoft created ADO.NET, an elegant, easy-to-use database API for managed applications. ADO.NET is exposed as a set of classes in the .NET Framework class library’s System. Data namespace and its descendants. Unlike ADO and OLE DB, its immediate predecessors, ADO.NET was designed from the outset to work in the connectionless world of the Web. It also integrates effortlessly with XML, bridging the gap between relational data and XML and simplifying the task of moving back and forth between them.

Disconnected Architectures: The architecture of ADO.net in which data retrieved from database can be accessed even when connection to database was closed is called as disconnected architecture. Disconnected architecture of ADO.net was built on classes connection, dataadapter, commandbuilder and dataset and dataview.

2. With the help of a suitable example, explain the steps involved in editing, compiling and running a C# program.

Ans:2The “Hello C#” Program: you can use any editor to code the program. It’s up to your convenience as to which editor to use. Below shows the coding for our “Hello C#” program:

using System;

Page 2: MC0081

MC0081 – .(DOT) Net Technologies ( Book ID: B0974)class Hello{public static void Main(){Console.WriteLine("Hello C#");}}After entering the above code in an editor, you have to perform the following steps Save the file as Hello.cs. cs is an extension to indicate C-Sharplike .java for a Java source file. You have to supply this extension while saving your file, otherwise the codewill not compile correctly. The saved file will be of the extension .cs.txt.Compile the code by giving the following command at the command prompt:csc Hello.csIf there are compile errors you will be prompted accordingly. Otherwise, you will be viewing a com-mandprompt along with the copyright information as shown in Figure 4.

As a final step, you have to execute the program in order to view the final output. For that purpose, you have to simply give a command as shown below at the command prompt. See Figure 4. If every-thing goes on well, then you can be able to view the message “Hello C#” as shown in the figure above.

3. Discuss the following: Web.config file Global.asax Application File

Ans:3 Web.config file: Web.config is the main settings and configuration file for an ASP.NET web applica-

tion. The file is an XML document that defines configuration information regarding the web applica-tion. The web.config file contains information that control module loading, security configuration, session state configuration, and application language and compilation settings. Web.config files can also contain application specific items such as database connection strings.ASP.Net Applications of XML have been integrated into such an extent that XML format for the ex-change of data, it's also used to store configuration settings.1. A Web application can contain more than one Web.config file. The settings in a file apply to the directory in which it's located, and all child directories. Web.config files in child directories take precedence over the settings that are specified in parent directories.2. Web.config files are protected by IIS, so clients cannot get to them. If you try to retrieve an ex-isting http://?????.com/Web.config file, you'll be presented with an "Access denied" error message.3. IIS monitors the Web.config files for changes and caches the contents for performance reasons. There's no need to restart the Web server after you modify a Web.config file.

Global.asax Application File: The Global.asax file is an optional file used to declare and handle ap-plication and session-level events and objectsfor an ASP.NET web site running on an IIS Web Server. The file contains ASP.NET program code, and is the .NET counterpart of the Global.asa file used for ASP. The Global.asax file resides in the IIS virtual root of an ASP.NET application.

Page 3: MC0081

MC0081 – .(DOT) Net Technologies ( Book ID: B0974)

At run time, upon the arrival of the first request, Global.asax is parsed and compiled into a dynami-cally generated .NET Framework class. ASP.NET is configured so that any direct request for the Global.asax is automatically rejected; external users cannot view or download the code in it.Code to handle application events (such as the start and end of an application) resides in Glob-al.asax. Such event code cannot reside in the ASP.NET page or web service code itself, since dur-ing the start or end of the application, its code has not yet been loaded (or unloaded). Global.asax is also used to declare data that is available across different application requests or across differ-ent browser sessions. This process is known as application and session state management.The Global.asax file must reside in the IIS virtual root. A virtual root can be thought of as the con-tainer of a web application. Events and state specified in the global file are then applied to all re-sources housed within the web application. If, for example, Global.asax defines a state application variable, all .aspx files within the virtual root will be able to access the variable.The ASP.NET Global.asax file can coexist with the ASP Global.asa file. A Global.asax file is created in either a WYSIWYG designer or as a compiled class that is deployed in an application's \Bin direc-tory as an assembly. However, in the latter case, the Global.asax file must refer to the assembly.Like an ASP.NET page, the Global.asax file is compiled upon the arrival of the first request for any resource in the application. The similarity continues when changes are made to the Global.asax file: ASP.NET automatically notices the changes, recompiles the file, and directs all new requests to the newest compilation.

4. Discuss the following: IIS Architecture IIS Request Processing Models

Ans:4 IIS Architecture: IIS Request Processin IIS 6.0 provides a redesigned World Wide Web Publishing

Service (WWW service) architecture that can help you achieve better performance, reliability, scalability, and security for your Web sites, whether they run on a single server running IIS or on multiple servers.IIS 6.0 runs a server in one of two distinct request processing models, called application isolation modes. Application isolation is the separation of applications by process boundaries that prevents one application or Web site from affecting another and reduces the time that you spend restarting services to correct problems related to applications.In IIS 6.0, application isolation is configured differently for each of the two IIS application isolation modes. Both modes rely on the HTTP protocol stack (also referred to as HTTP.sys) to receive Hy-pertext Transfer Protocol (HTTP) requests from the Internet and return responses. HTTP.sys resides in kernel mode, where operating system code, such as device drivers, runs. HTTP.sys listens for, and queues, HTTP requests. For more information about HTTP.sys, see HTTP Protocol Stack.The new request-processing architecture and application isolation environment enables individual Webapplications, which always run in user mode, to function within a self-contained worker process. A worker process is user-mode code whose role is to process requests, such as returning a static page or invoking an Internet Server API (ISAPI) extension or filter. Worker processes use HTTP.sys to receive requests and send responses over HTTP. For more information about worker processes, see Worker Processes.

Page 4: MC0081

MC0081 – .(DOT) Net Technologies ( Book ID: B0974)

Figure: Architecture of IIS 5.0 Isolation Mode

IIS Request Processing Models : Worker process isolation mode is the new IIS request processing model. In this application isolation mode, you can group Web applications into application pools, through which you can apply configuration settings to the worker processes that service those ap-plications. An application pool corresponds to one request routing queue within HTTP.sys and one or more worker processes.

Worker process isolation mode enables you to completely separate an application in its own process, with no dependence on a central process such as Inetinfo.exe to load and execute the ap-plication. All requests are handled by worker processes that are isolated from the Web server it-self. Process boundaries separate each application pool so that when an application is routed to one application pool, applications in other application pools do not affect that application. By using application pools, you can run all application code in an isolated environment without incurring a performance penalty. For more information about application pools, see How Application Pools Work.For a visual representation of worker process isolation mode architecture, see Figure. Worker process isolation mode delivers all the benefits of the new IIS 6.0 architecture, including multiple application pools, health monitoring and recycling, increased security and performance, improved scalability, and processor affinity. For example, the new health monitoring features can help you discover and prevent application failures, and can also help protect your Web server from imper-fect applications. IIS 5.0 isolation mode provides compatibility for applications that were designed to run in earlier versions of IIS. When IIS 6.0 is running in IIS 5.0 isolation mode, request processing is almost identical to the request processing in IIS 5.0. When a server is working in IIS 5.0 isolation mode, application pools, recycling, and health monitoring features are unavailable.

For a visual representation of IIS 5.0 isolation mode architecture, see Figure 2.2. The dashed line in Figure 2.2 indicates the dependency of the worker process on the WWW service, which manages the worker process.

Page 5: MC0081

MC0081 – .(DOT) Net Technologies ( Book ID: B0974)

Use IIS 5.0 isolation mode only if components or applications do not function in worker processisolation mode. The latter mode is designed to provide an environment in which most existingapplications or sites function correctly.