Home
Home Page
And again about functional programming on Python
Where the Python has come crawling?
Practical application OOP in PHP5
Functional programming in language Python
Approaches of language Python - an amusing example of optimization
Use ext/mysqli: Part I - the Review and the prepared expressions
How to receive the maximal result from registration in catalogues
XML-RPC In language Python
The API-specification of databases of language Python, version 2.0
Programming of the Web-client in language Python
Useful advice for job with XML
Future Web - behind semantics
Whether it is necessary to cancel spaces of names XML?
Use AJAX in ASP.NET
ASP .NET 2.0: Reference pages
Patterns of registration
What is ASP.NET. Installation and the test project.
Anatomy ASP.NET. ASP.NET in operation.
Server elements of management Continuation.
Links
 
topic


What is ASP.NET. Installation and the test project.

Introduction


Microsoft .NET Framework is a platform for creation, expansions and start of Web-services and applications. She gives high-efficiency, based on standards, the multilanguage environment which allows to integrate existing applications with applications and services of the following generation, and also to solve problems{tasks} of expansion and use of Internet - applications. .NET Framework will consist of three basic parts - the nontechnical environment of performance (common language runtime), hierarchical set of the unified libraries of classes and the componental version ASP, named ASP.NET.


ASP.NET is a part of technology .NET, used for a spelling powerful client-server the Internet of applications. She allows to create dynamic pages HTML. ASP.NET has arisen as a result of association of older technology ASP (active server pages) and .NET Framework. She contains set of ready elements of management, using which it is possible to create interactive web-sites quickly. You also can use the services given by other sites, is transparent for users of your site. In general, opportunities ASP.NET are limited only to your imagination.


Let's discuss, that such dynamic pages HTML and than they differ from static. The static page contains a code in language of hypertext marking HTML. When the author of page writes her{it}, he defines{determines}, how the page for all users of page will look. The maintenance{contents} of page will be always identical irrespective of, who and when will decide her{it} to see{overlook}. It is quite enough language HTML for display of the information which seldom changes and does not depend on the one who looks through her{it}. Page HTML - the simple ASCII-text, hence, the client can work in any operational system.


Completely understandably, that if to generate web-page, having described its{her} structure means HTML, she will be completely static in sense of contents. That is at viewing in a browser she will bear{carry} in herself precisely the same information, that in it{her} has been written down at the moment of creation, and the data transferred{handed} by the user cannot be used for updating contents of pages displayed to him: he can see only that has preliminary been written down in a final set of files.


But what, if we want to display the current rate of euro or weather forecast on page? If we have written page HTML yesterday, today she will already become outdated. Hence, we should be able to create dynamic pages. Dynamic filling of page is an information which maintenance{contents} is defined{determined} by that to whom she is intended and which differs from viewing to viewing. It allows to provide bilateral information interchange - from the client to the server and back.


Dynamic it is accepted to name web-pages which before sending to the client pass an operation cycle on the server. In the most simple case it can be some program which modifies static pages required by the client, using parameters of the received search and some storehouse of the data. Even at such primitive organization the "unsoluble" problem{task} from the previous paragraph finds the obvious decision: it is enough to prepare only one static page - a pattern - and before sending of page programmno to substitute in him{it} the value received today from bank or meteobjuro.


The majority of pages at early stages of development of the Internet were static. Last 10 years the quantity{amount} of dynamic pages grows. And it is understandable, users the Internet want not only to read the ready information, and to be active characters. For example, they reserve the goods in Internet - shop, write diaries, participate in competitions. Information portals update news every minute. Dynamic pages can be arranged under the concrete user, and also react to his{its} actions in a browser. In what image? For this purpose the set of technologies is thought up. For example, to identify the user and to save his{its} adjustments for the given site, files - cookies are applied.


There are the languages capable dynamically to change contents of web - page. On the one hand, it is the languages of scripts which are carried out directly at the client. Examples skriptovykh languages - JavaScript and VBScript. Scripts in these languages are built - in code HTML, which server sends a browser. The scripts which are carried out on the party{side} of the client, are allocated tegami and. The browser interprets this code and shows the user result. The code can be seen{overlooked} through View Source a browser. Naturally, these programs cannot be big. For example, if it is necessary to execute search in a database, we cannot send the user all its{her} contents. But scripts can check up correctness of the search entered into the form then it is not necessary to reload the server processing of wrong searches. Some programmers create on JavaScript animation effects. One student intuit.ru wished to find a script which would send SMS-messages. Alas, it is impossible. Carried out on the party{side} of the client of scripts it is not enough for creation of high-grade dynamic pages. Even if on page it is used JavaScript, animated a picture .gif, she is called static.


Dynamic to web - page should be created "hurriedly" by the program executing on the Internet - server. Are widely applied the mechanism of gateways CGI (Common Gateway Interface). In the beginning the user receives static page with the form. You know, that in tege FORM there is attribute ACTION. he sets (URL address of the executed application. On the server there are executed files of the programs written, for example on C/S ++ or Del`fi which under report HTTP accept the data from an entrance stream or from variables of an environment and write down in a standard target stream ready page.


To the user in reply to search it is sent HTML a code which has been specially generated for him{it}. It can be, for example, result of search in the search engine. CGI scripts can be written in interpretive language (Perl) or even a script of the command line. Entrance and target streams are renominated. On an input{entrance} the Internet - server accepts the data entered by the user. After processing the received data, to the user the resulting page comes back. At execution{performance} the cgi-program is loaded into memory of the server, and at end - leaves. When 100 clients simultaneously address to the server, in memory 100 processes are created, memory is necessary for accommodation of a code of each of which. It has an adverse effect on scalability. We shall remind, that scalability is an opportunity of smooth growth of time of the answer of program system on search with growth of number of simultaneously working users.


For the decision it is problems Microsoft the alternative - ISAPI (Internet Server Application Programming Interface) expansions and filters has been offered. Instead of executed files are used DLL - libraries. Code DLL is in memory all time and for each search creates not processes, and strings of execution{performance}. All strings use the same program code. ISAPI the application is carried out during the IIS-server. It allows to raise{increase} productivity and scalability.


ISAPI-expansions can be created in Visual Studio C ++ 6.0, using the master.


At ISAPI too there are the lacks concerning to development. If we change an initial code dll, we owe it{him} otkompilirovat` and place in an executed directory of the server. But as the previous variant dll is in memory, it is necessary to stop the server to get access on change of a file. At this time clients cannot receive in the server any document, and, certainly, will be not satisfied.


Skriptovye the languages executing on the party{side} of the server - php and asp. The technology asp has been developed Microsoft in 90th years.


Performance of a code asp is supported by ISAPI-expansion of the server. In dialogue of a configuration of IIS server ways of processing of files with various expansions are defined{determined}. For processing the URL-address with expansion in installations of the server the file asp.dll is determined. Files asp are sent to it{him} on processing. On an input{entrance} acts asp, and on an output{exit} we have a stream of a HTML-code.


Example of a file asp:



<% Language=VBScript %>

  <% Option Explicit of %>

  <HTML>

  <HEAD>

  <META HTTP-EQUIV = "Content-Type" content = "text/html">

  <TITLE>

  Hello ASP World!

  <TITLE>

  </HEAD>

  <BODY>

  <P> <%

  Dim i;

  for i=1 to 5

  Response. Write (” <FONT SIZE = “ and i)

  Response. Write (”> This code generates ASP! </FONT> “)

  next i

  %>; </P>

  </BODY>

  </HTML>


Teg <%... %> signals asp, that in him there is a code which he should process on the server. The script in language which is specified in Language directive is carried out. Operator Response. Write writes down the text in a target stream of the server, thus, he becomes a part of the HTML-page, sent to the user.


The technology asp has been limited by the opportunities. He used skriptovye languages which have less opportunities, than full-function programming languages. The code asp has been built - in in HTML as special tegov, that created mess. Slices asp have been scattered on it{him}, as raisin in a roll. But HTML the code is created usually by designers who are able « to do{make} beautifully », and asp - programmers who force all this to work. In ASP.NET you can hold a code asp and HTML in different files.


Skriptovye languages do not support strict typification. What does it mean? You can not describe a variable before its{her} use and can appropriate{give} to her values of different types. It is convenient, but creates ground for mistakes. For example, you have variable x1, and you appropriate{give} to her value 1, but you have made a typing error and have by mistake written x2=1. the new variable x2 will be created, and value x1 will not change. In language with strict typification the compiler will notice, that the variable x2 was not described, and will give out a mistake.


In 2000 at conference of developers as a part of new technology .NET Microsoft has presented ASP +. With an output{exit} .NET Framework 1.0 she began to be called ASP.NET.


ASP.NET is not continuation ASP. It is conceptually new technology Microsoft created within the framework of ideology .NET. In everything ASP.NET is incorporated to make all cycle of development of the web - application faster, and support more simple. ASP.NET it is based on object-oriented technology, but has saved model of development asp: you create the program and place her{it} in a directory selected with the server, and she will work. In many new functions ASP.NET have appeared, and existing in asp are considerably advanced.


In ASP.NET are used kompiliruemye languages. During compilation the syntactic correctness of the initial text is checked. The code compiled in intermediate language is carried out faster, and he will be same irrespective of language which we use. Kompiliruemye languages support strict typification.


Compilation occurs on the server at the moment of the first reference{manipulation} of the user to page. If the programmer has changed the text of page, the program perekompiliruetsja automatically. At a spelling of a code it is possible to use a set of the components delivered with .NET.


The platform .NET Framework gives applications the environment of performance, itself directly cooperating with operational system. The interface ASP.NET applications above lays, on which webs - forms (ASP.NET pages) and webs - services are in turn based. The interface .NET Framework allows to standardize the reference{manipulation} to system calls and gives environment{Wednesday} for faster and convenient development. CLR provides a uniform set of services for all languages.


ASP.NET uses technology of a data access ADO.NET which provides the uniform interface for access to databases SQL Server and files XML. Besides the amplified{strengthened} model of safety allows to provide protection of the client and the server against the non-authorized access.


In 2004 the version ASP.NET 2.0 (the beta-version, a final output{exit} - the end the 2005-beginning 2006) has appeared. As affirms, this version allows to reduce volume of coding to 70 %. New opportunities of version 2.0 - for example, use of patterns of design of pages (Master Page), the simplified localization of Web-applications, more than 50 new server elements of management. The purposes which were pursued by developers of the new version - to raise{increase} speed of development of sites, scalability, ease of support and administration of sites, speed of job of the server. The panel ostnastki MMC (the console of management Microsoft), giving the graphic interface for management of adjustments ASP.NET has appeared. To change adjustments of the project now it is possible and through the web-interface. ASP.NET 2.0 supports job on 64-bit processors. Service of personification (personalization) gives the ready decision for storage of the personal data directly describing the user of a site, a so-called structure of the user (Profile).


Patterns of design, subject and skiny allow independently design of all site separately from his{its} functionality, subjects include to the schedule and cascade tables of styles.


Previous versions Visual Studio for projects ASP.NET demanded presence by the machine of the developer of IIS server. Now the server is built - in Wednesday of development.


ASP.NET 2.0 and Visual Studio 2005 give tools for easy construction of localized sites which define{determine} preferred language of the user and send him pages in his{its} language.


The opportunity prekompiljacii allows to find out mistakes before loading pages on the server. It is possible to not store{keep} on the server initial pages aspx, thus protecting the intellectual property.


In ASP.NET 2.0 the technology of automatic updating of caching of databases is built - in. The data received from base, are stored{kept} on the server and he does not address to base for processing repeated search. At change of a database the cache updates the contents.


ASP.NET is a technology, instead of language, and allows to program in different languages - With *, Visual Basic, J *. .NET all languages are equal a platform, but the some people ravnee (Dzh. Oruehll). Such language also is With * because he has been specially created for this platform. Programming C * allows to use to the full concepts, methods and patterns of object-oriented development. Language Visual Basic 8.0 is allocated almost the same opportunities. To learn ASP.NET, you need to know bases HTML, and the knowledge asp is not necessary. It can even prevent, as it is necessary to change a mentality. Also for understanding of many it is desirable to know CSS and JavaScript.



Process of installation


ASP .NET 2.0 it is possible to establish on computers from OS Windows 2000 with Service Pack 4, Windows XP with Service Pack 2 and later versions Windows. Ready sites are preferable for establishing on Windows Server 2003.


For development of the application it is possible to use any environment of development or even the text editor provided that you have access to IIS. If you want to use all power Microsoft .NET Framework and ASP.NET and thus, to spend as small as possible efforts it is necessary to use the environment of the development specially developed for programming ASP.NET 2.0.


If you will get Visual Studio .NET 2005 for job will be only it{him} enough. .NET Framework contains on disks. Into his{its} structure enters Visual Web Developer which allows to create professional webs - applications, and also desktop-applications in different programming languages. Products Microsoft are issued on DVD, but there is a set from two CDs from "Megasoftware". Visual Studio .NET 2005 demands about 2 Gigabytes of disk space. Thus the environment of development, SQL Server Express, the built - in web - server, Crystal Reports with special elements of management for ASP.NET 2.0 will be installed ASP.NET 2.0.

Free-of-charge distributed software.


Visual Web Developer 2005 Express Edition - freely distributed environment intended for newbies and the students, accessible to the address http://msdn.microsoft.com/vstudio/express/vwd/. The list of differences VWD from Visual Studio.NET 2005 is insignificant and for beginning{starting} is insignificant, he is resulted here: http://msdn.microsoft.com/vstudio/products/compare/default.aspx


VWD installer has volume of 2,8 Mb, but during installation he will load 40 more Mb and 80 Mb if want to establish the documentation. Thus also it will be established .NET Framework with ASP.NET 2.0.


System requirements - the processor with the minimal speed of 600 MHz, 128 MB of memory and 1.3 GB disk space. After installation it will be necessary to register the installation, it completely free-of-charge.


As Wednesday of development you can choose WebMatrix. This program combines in itself the editor and the http-server. She{it} can be loaded on http://www.asp.net/WebMatrix.


At WebMatrix the installer in the size of only 1.2 Mb, but at him{it} is less than opportunities, than at VWD. But, in general, these Wednesdays development are similar. At WebMatrix there is a unpleasant feature - she gives search about preservation during closing files which were not edited. VWD Express allows to open one pressing of the button the Web-interface konfigurirovanija the project. In VWD technology IntelliSense which automatically offers possible{probable} in the given place elements of a code works.


If you have decided to work with WebMatrix, you should establish by the machine .NET Framework 2.0 and ASP.NET 2.0.


If at you operational system Windows Server 2003.NET Framework already predustanovlen. You can check up, whether there is you a directory %WINSDIR%Microsoft. NETFramework. If no, you can load her{it} on site Microsoft. Last versions are to the address http://msdn.microsoft.com/netframework/downloads/updates


At present it .NET Framework 2.0, but by the moment when you will read this lecture, newer versions can appear. You can download the new version even if you already have another. They will exist on a computer simultaneously in subdirectories %WINSDIR%Microsoft. NETFramework, with a name corresponding to number{room} of the version. It is possible to say, that each version represents assembly. The system of versions is supported for all applications created with use .NET Framework.


There you will see links on .NET Framework for different architecture of a computer.


At desire load .NET Framework Version 2.0 SDK which contains alongside with .NET Framework Version 2.0 SDK documentation and examples which can appear useful.


To the address http://asp.net/default.aspx it is possible to find many software products useful to developers, examples of a code and clauses{articles}.


IIS (Internet Information Server) is on install disk Windows 2000/XP, but predustanovlen only on servers. It{he} can be established, zajdja in Control Panel-> Add or Remove Programs-> Add/Remove Windows Components. The computer will ask you to insert an install disk.


IIS it can be necessary, if the high-grade server is necessary for job in the Internet for you, instead of is simple on the computer or in a local area network or you have decided to type{collect} the text in the usual editor. For job on the computer on all these Wednesdays development Cassini server which has originally appeared as part WebMatrix is built - in. Symbol WebMatrix - a planet Saturn, and Kassini - the known researcher of Saturn. Previous versions Visual Studio demanded presence IIS, but now Cassini is built - in and in Visual Studio 2005, that allows to work even in Windows XP Home Edition.


Examples will be given as for WebMatrix, and Visual Studio. Some examples demand VWD Express or Visual Studio.

Communities of developers.


Through the menu of help Visual Web Developer Express it is possible to go on sites of a forum on ASP.NET. And addresses of sites in Russian:


* http://www.aspnetmania.com

* http://www.gotdotnet.ru/

* http://www.sql.ru/

* http://dotsite.ru/

* http://www.rsdn.ru/


You can get{start} a trial hosting on http://europe.webmatrixhosting.net/russia/default.aspx.



The first project


In the beginning decide, in what directory will create pages. All files which are taking place in one directory, are considered as the uniform project. Start the environment of development chosen you. Choose item{point} of menu File-New-Website. The dialog box will appear. Appoint in him a name of the project and choose the programming language With *.


By default the project is created in file system. At the request of it{him} it is possible to create on HTTP or the FTP-server. From file system the project always can be copied on the server pressing of one button in heading Solution Explorer.


In the project the page default.aspx will be created. Choose her{it}, and the window of editing with bookmarks Design and Source. not changing anything will appear, click on the button with an arrow{a pointer} to see{overlook} page in a browser. The window which it is asked will appear, whether it is necessary to add in a file web.config an opportunity of debugging. Press OK. On the panel of problems{tasks} the badge of the web - server should appear. The browser showing page to the address http: // localhost:nomerporta/Website1/default.aspx. localhost the server working on your computer will open designates. Built - in Cassini server itself appoints to itself number{room} of port - for each project he different. IIS server usually works through port 80 (or 8080 if that is borrowed{occupied}), and for him{it} number{room} of port to specify it is not necessary. Thus your page will be compiled.


Meanwhile page in brazere empty.


But an initial code of this page not empty. The program has generated a code for you.



<% Page Language = " C * " AutoEventWireup = "true" CodeFile = "Default.aspx.cs" Inherits = " _ Default " %>

  <! DOCTYPE html PUBLIC " - // W3C // DTD XHTML 1.0 Transitional // EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns = " http: // www.w3.org/1999/xhtml ">

  <head runat = "server">

      <title> Untitled Page </title>

  </head>

  <body>

      <form id = "form1" runat = "server">

      <div>

      </div>

      </form>

  </body>

  </html>


Let's disassemble this page.


<% Page Language = " C * " %>. Teg <% always intends for interpretation of a ASP-code. Page directive always is present on page aspx. Its{her} attribute Language is an instruction{indication}, that in scripts of the given page will be used C *, and could VB, C ++ or J *. CodeFile - a name of a file with the separated code (code-behind.) Inherits - a class determined in this file from which the class of page is inherited.


File Default.aspx.cs will be simultaneously created also.


It is technology of division of a code about which we already spoke. The form is in file Default.aspx, and file Default.aspx.cs there is a class of page in language C *. Thus, the design of page can be changed not mentioning a code of page that allows to divide{share} the responsibility for appearance and job of page between the designer and the programmer.



<form runat = "server">


This teg gives the instruction{indication} to the compiler to process elements of management of page. Pay attention that given teg has property runat for which value "server" (other values is established and it does not happen). At use of this property the element of management is processed by the compiler, instead of passed a browser « as is ».


Insert in Default.aspx between tegami <form> and </form> teg, a specifying element of management.



<asp:Label id = "Time" runat = "server"

   Text = “ the Server is in Moscow. Moscow time: “

/>


The server element of management Label is means of accommodation for page of the text which can contain tegi HTML. Changing values of properties of this element of management in a code, you can dynamically change the text on page. In asp:Label to the compiler it is informed, with what object job (in a considered{an examined} case - with an element of management Label) is conducted.


Further various properties of an element of management are set. First of all his{its} name id = "time" and attribute "runat", and also the text is defined{determined}.


In file Default.aspx.cs such text should contain:



using System;

  ......

  public partial class _Default: System. Web. UI.Page 

  {

      protected void Page_Load (object sender, EventArgs e)

      {

           

}

}


The keyword partial has appeared in C * 2.0, and allows to break the text of definition of a class between different files.



System. Web. UI.Page - a class, base for all pages ASP.NET.


If you work with WebMatrix, insert it{him} independently between tegami <script> and </script> a file default.aspx.


Insert into this function a line



Time. Text = DateTime. Now. ToString ();


Probably, you are already familiar with class System. DateTime of library of classes FCL - to a component .NET Framework. Here we use this class, as in any program on C *. Hence, any class .NET is accessible both in local, and in the distributed{allocated} applications.


The received value is appropriated{given} to property Text of object time. It is an element of management such as Label (label) which we have inserted. Time for hours of the client and the server can not coincide, if they are in different points of globe.


Page_Load It is similar on usual obrabotchik events of the form. As it is possible lekgo to guess, this function is caused each time when the form is loaded.


Start page on viewing by button F5 or having pressed on the button with an arrow{a pointer} on a toolbar. In a browser the page on which current time will be written should open. Open the initial text of page. Any code on With * or elements of management ASP.NET there will not be.



<! DOCTYPE html PUBLIC " - // W3C // DTD XHTML 1.0 Transitional // EN " "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

  <html xmlns = " http: // www.w3.org/1999/xhtml ">

  <head> <title> Time, forward </title>

  </head>

  <body>

      <form name = "form1" method = "post" action = "Default.aspx" id = "form1">

  <div>

  <input type = "hidden" name = " __ VIEWSTATE " id = " __ VIEWSTATE " value = "/wEPDwUJODExMDE5NzY5D2QWAgIDD2QWAgIBDw8WAh4EVGV4dAUSMDguMDYuMjAwNiA0OjU2OjQ3ZGRkkEMg = "/>

  </div>

  <div>

       <span id = "Time"> the Server is in Moscow. Moscow time: 08.06.2006 4:56:47 </span>

      </div>

      </form>

  </body>

  </html>


Update page. You will see new value of time.


You can see{overlook} page with the help of any other browser.


If you are in a network, and Internet connection is carried out through a proxy, put a tick on page Connections (for IE) Bypass proxy server for local addresses.



The conclusion


ASP.NET 2.0 to study uneasily, but due to its{her} componental model the prize will consist in acceleration of development in comparison with other technologies.