Documente Academic
Documente Profesional
Documente Cultură
A class is a construct that enables you to create your own custom types by grouping together variables of other
types, methods and events. A class is like a blueprint. It defines the data and behavior of a type. If the class is not
declared as static, client code can use it by creating objects or instances which are assigned to a variable. The
variable remains in memory until all references to it go out of scope. At that time, the CLR marks it as eligible for
garbage collection. If the class is declared as static, then only one copy exists in memory and client code can only
access it through the class itself, not an instance variable. For more information, see Static Classes and Static Class
Members (C# Programming Guide).
EXAMPLE
// Constructor
public Person()
{
name = "unknown";
}
// Method
public void SetName(string newName)
{
name = newName;
}
}
class TestPerson
{
static void Main()
{
Person person = new Person();
Console.WriteLine(person.name);
person.SetName("John Smith");
Console.WriteLine(person.name);
– Listing 1 –
using System;
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
Compile the code by giving the following command at the command prompt:
csc Hello.cs
If there are compile errors you will be prompted accordingly. Otherwise, you will be viewing a command
prompt 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 everything goes on well, then
you can be able to view the message “Hello C#” as shown in the figure above.
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 existing
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.
The Global.asax file must reside in the IIS virtual root. A virtual root can be thought of as the container of a web
application. Events and state specified in the global file are then applied to all resources 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 directory 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.
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 Hypertext Transfer Protocol
The new request-processing architecture and application isolation environment enables individual Web
applications, 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.
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 application. All requests are handled
by worker processes that are isolated from the Web server itself. 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 imperfect 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.
Use IIS 5.0 isolation mode only if components or applications do not function in worker process
isolation mode. The latter mode is designed to provide an environment in which most existing
applications or sites function correctly.
By creating new application pools and assigning Web sites and applications to them, you can make your server
more efficient and reliable, and your other applications always available, even when the applications in the new
application pool terminate.
Procedures
To create a new application pool
1. In IIS Manager, double-click the local computer, right-click Application Pools, point to New, and then
click Application Pool.
2. In the Application pool ID box, type the name of the new application pool.
3. Under Application pool settings, click either Use default settings for new application pool or Use existing
application pool as template.
4. If you selected Use existing application pool as template, from the Application pool name list box, click the
application pool to be used as a template.
5. Click OK.
Web services are externally exposed systems that allow applications to talk to each other and share information
over a network. The web service standards are built upon other standards such as HTTP or XML and are not
reliant upon any proprietary systems. The Web service is itself a collection of methods that can be called from a
remote location so that these methods accept and return parameters and provide for a wide variety of
functionalities that can be used internally in the application that is exposed to the public.
The concept behind web services is not new. The ad hoc methods of tying applications together have merely given
place to organized methods of communications between applications. Standardized specifications have also
lowered costs and shortened development timelines.
Prior to the emergence of Visual Studio.NET in the market a number of technologies attempted to cater to the
needs of the Web based world. Let us briefly look at the various technologies that tried to address these issues.
The .disco document is an XML document that simply contains links to other resources that describe the Web
Service, much like an HTML file that contains human-readable documentation or a WSDL file containing the
interface contract. The following is a DISCO document skeleton that will serve as a starting point.
<disco:discovery
xmlns:disco="http://schemas.xmlsoap.org/disco/">
<!-- references go here -->
</disco:discovery>
Notice that the root element has the name discovery from the http://schemas.xmlsoap.org/disco/ namespace.
The references to other resources are placed within the discovery element:
<disco:discovery
xmlns:disco="http://schemas.xmlsoap.org/disco/"
xmlns:scl="http://schemas.xmlsoap.org/disco/scl/">
<!-- reference to other DISCO document -->
<disco:discoveryRef
ref="related-services/default.disco"/>
<!-- reference to WSDL and documentation -->
<scl:contractRef ref="math.asmx?wsdl"
docRef="math.asmx"/>
</disco:discovery>
The main element is contractRef, which belongs to a different namespace than the rest of the DISCO-related
elements. contractRef has two attributes, ref and docRef, which point to the WSDL and documentation files for a
given Web Service.
The discoveryRef element lets you link the given DISCO document to other DISCO documents. This linking
allows you to create a Web of related DISCO documents spanning multiple machines and even multiple
organizations. This is especially useful if the DISCO client utility provides a mechanism to traverse the links.
These are the only elements that you have to be concerned about in the DISCO namespace.
DISCO Redirects
Up to this point, all of the examples have required the client to specify the exact address of the .disco file on
the server. In most situations prospective clients won't know the exact address of the .disco file, so DISCO also
makes it possible to provide hints in the vroot's default page.
If the vroot's default page is an HTML document, you can use the LINK tag to redirect the client to the .disco
file:
If the vroot's default page is an XML document, you can use the xml-stylesheet processing instruction to
accomplish the same thing:
Using UDDI
UDDI includes the shared operation of a business registry on theWeb. For themost part, programs
and programmers use the UDDI Business Registry to locate information about services and, in the
case of programmers, to prepare systems that are compatible with advertisedWeb services or to
describe their ownWeb services for others to call. The UDDI Business Registry can be used at a
business level to check whether a given partner has particularWeb service interfaces, to find
companies in a given industry with a given type of service, and to locate information about how a
partner or intended partner has exposed aWeb service in order to learn the technical details required
to interact with that service.
After reading this paper, the reader will have a clearer understanding of the capabilities defined in the
UDDI specifications and have a clearer understanding of the role ofWeb service registries that
implement these specifications.
Using the UDDI discovery services, businesses individually register information about theWeb services
that they expose for use by other businesses. This information can be added to the UDDI business
registry either via aWeb site or by using tools that make use of the programmatic service interfaces
described in the UDDI Programmer’s API Specification. The UDDI business registry is a logically
centralized, physically distributed service withmultiple root nodes that replicate data with each other on
a regular basis. Once a business registers with a single instance of the business registry service, the
data is automatically shared with other UDDI root nodes and becomes freely available to anyone who
needs to discover whatWeb services are exposed by a given business.
Automatic compilation.
ASP.NET automatically compiles your application code and any dependent resources the first time a user requests
a resource from the Web site. In general, ASP.NET creates an assembly for each application directory (such as
App_Code) and one for the main directory. (If files in a directory are in different programming languages, then
separate assemblies will be created for each language.) You can specify which directories are compiled into single
assemblies in the Compilation section of the Web.config file.
Layered application designs are extremely popular because they increase application performance, scalability,
flexibility, code reuse, and have a myriad of other benefits that I could rattle off if I had all of the architectural
buzzwords memorized. In the classic three tier design, applications break down into three major areas of
functionality:
The data layer manages the physical storage and retrieval of data
The business layer maintains business rules and logic
The presentation layer houses the user interface and related presentation code.
Inside each of these tiers there may also exist a series of sub-layers that provide an even more granular break up
the functional areas of the application.
The Figure outlines a basic three tired architecture in ASP.NET along with some of the sub-tiers that you may
encounter: