1. Trang chủ
  2. » Công Nghệ Thông Tin

Giới thiệu ASP.NET ppsx

28 246 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 28
Dung lượng 868,96 KB

Nội dung

Introducing ASP.NET Chapter 1 Web applications have revolutionized the way business is conducted. These applications enable organizations to share and access information from anywhere and at anytime. This has majorly moved the focus of application development from desktop applications to Web applications. One of the most popular server-side technologies used today for developing Web applications is ASP.NET. This chapter introduces the basics of Web development. It also discusses the architecture, functioning, and features of ASP.NET. In addition, it explains how to develop ASP.NET applications. In this chapter, you will learn to:  Identify the basics of Web development  Explore ASP.NET  Develop ASP.NET applications Objectives NIIT Introducing ASP.NET 1.3 Among all technologies, the Internet has been the fastest growing technology. Ever since its inception, the Internet has evolved exponentially. In the recent years, it has changed the way business is conducted. Prior to the evolution of the Internet, organizations were unable to create awareness about themselves because the communication media were limited. Moreover, the organizations could deliver only limited information by using the existing communication media such as television and radio. However, with the inception of the Internet, organizations found a new medium through which they could reach a larger range of people irrespective of their geographical locations. Therefore, organizations increasingly became dependent on the Internet for sharing and accessing information. This resulted in changing the focus of application development from desktop applications to Web applications. Web applications are programs that are executed on a Web server and accessed from a Web browser. These applications enable organizations to share and access information on the Internet and corporate intranets. This information can be accessed from anywhere and at any time. In addition, Web applications can support online commercial transactions popularly known as e-commerce. An online store accessed through a Web browser is an example of a Web application. A Web application consists of Web pages. Web pages can be of the following types:  Static Web page: A Web page that consists of only Hyper Text Markup Language (HTML) is a static Web page. A static Web page does not respond dynamically to the actions performed by a user.  Dynamic Web page: A Web page that responds dynamically to the actions performed by a user is a dynamic Web page and an application that consists of dynamic Web pages is a dynamic Web application. Such an application can be created by using server-side scripts, client-side scripts, or both in addition to HTML pages. With the increase in the usage of the Internet as the information medium, organizations are creating dynamic Web applications. Dynamic Web applications enable a user to:  Retrieve data from a database that may not reside on the computer where the Web server is located.  Submit data from HTML forms.  Get information based on the input. Introducing Web Development Server-Side Scripting 1.4 Introducing ASP.NET NIIT To incorporate these features in a Web application, you need to implement server-side scripting. Server-side scripting provides users with dynamic content that is based on the information stored at a remote location, such as a back-end database. Server-side scripting includes code written in server-side scripting languages, such as Active Server Pages (ASP) and Java Server Pages (JSP). A server-side script is executed on the Web server. When a browser requests for information on a website that is created by using server-side technology, the Web server to which the request is sent, first processes the script and then sends the results back to the browser. For example, if a Web page includes a server-side script to display the current time of the system on which the website is hosted, the script will be processed at the server and the current system time will be sent back to the browser. The following figure shows the working of server-side scripts. Working of Server-Side Scripts Client-side scripting enables you to develop Web pages that can dynamically respond to user input without having to interact with a Web server. Suppose, you have a Web application that requires users to enter the user name and password before displaying the home page. You need to ensure that a user does not leave the user name and password fields blank. To check whether a user has left the user name and password fields blank, you can write client-side scripts. Client-Side Scripting NIIT Introducing ASP.NET 1.5 In addition to providing dynamic content, a client-side script helps reduce network traffic because it does not need to interact with a Web server to provide dynamic response to the user input. Client-side scripting also speeds up the response time of a Web application. This happens because a Web server is not overloaded with the job of processing the client-side script for every client. Scripting languages, such as VBScript and JavaScript, are used to write client-side scripts. The following figure shows the working of client-side scripts. Working of Client-Side Scripts Limitations of Client-Side Scripting In spite of the all the advantages, client-side scripting has some major limitations. These limitations are:  Browser support: Client-side scripting is not supported equally by all browsers and operating systems.  Isolation: Client-side scripts cannot access server-side resources. It is difficult and requires a lot of coding to access a file or interact with a database on the server by using client-side scripts.  Security: Client-side scripts are visible to the end users. Therefore, they can be tampered by malicious users. 1.6 Introducing ASP.NET NIIT N ot e  Thin clients: Web-enabled devices such as mobile phones, palmtop computers, and Personal Digital Assistants (PDAs) can communicate with Web servers. These devices act as thin clients that can use Web applications containing server-side scripting. However, these devices do not support client-side scripting such as JavaScript or VBScript. In spite of all the limitations, client-side scripting is still in use. ASP.NET allows you to use client-side scripting in addition to the server-side scripting to create rich and responsive Web applications. NIIT Introducing ASP.NET 1.7 ASP.NET is a server-side technology that enables programmers to create dynamic Web applications. It has a number of advanced features such as simplicity, security, and scalability that help you develop robust Web applications. These advanced features of ASP.NET are based on the .NET Framework. ASP.NET is built on the Microsoft .NET Framework. Microsoft introduced the .NET Framework to help developers create globally distributed software with Internet functionality and interoperability. The following figure displays the elements of an ASP.NET application and how the elements fit in the broader context of the .NET Framework. Elements of an ASP.NET Application in the .NET Framework The preceding figure indicates that an ASP.NET application has the following elements:  Web Form pages: Enable you to include user interfaces, such as Text box control, List box control, and the application logic of Web applications. Exploring ASP.NET A SP.NET in the .NET Framework 1.8 Introducing ASP.NET NIIT  Configuration files: Enable you to store the configuration settings of an ASP.NET application.  XML Web Service files: Define a Web service that can be called by an ASPX file over the Internet or from a local network. Web forms and the state management feature of ASP.NET constitute the ASP.NET Page Framework. There are also a number of runtime services available in ASP.NET. The ASP.NET runtime services include view state, session state, and application state management, Web security, and the caching mechanism of ASP.NET applications. The runtime services of ASP.NET interact with .NET Framework base classes, which in turn, interact with the Common Language Runtime (CLR) to provide a robust Web-based development environment. After creating an ASP.NET application, the ASP.NET files need to be stored on a Web server such as Internet Information Services (IIS) server, which is the Web server for the Windows platform. The Web server processes the ASP.NET files and then executes the scripts. Finally, the results are sent to the Web browser that requested the ASP.NET file. The following figure depicts how a Web server processes a request for an ASP.NET file. Processing of a Request for an ASP.NET File W orking of an ASP.NET Application NIIT Introducing ASP.NET 1.9 N ot e The steps involved in the execution of an ASP.NET file are: 1. A Web browser sends a request for an ASP.NET file to a Web server by using a Uniform Resource Locator (URL). 2. The Web server, such as IIS, receives the request and retrieves the appropriate ASP.NET file from the disk or memory. 3. The Web server forwards the ASP.NET file to the ASP.NET script engine for processing. 4. The ASP.NET script engine reads the file and executes any server-side script it encounters. 5. The processed ASP.NET file is generated as an HTML page. 6. The Web server then sends the HTML page to the client. 7. The Web browser interprets the output and displays it. A Web server generates and sends only the HTML output to the client. As a result, it helps to hide the code of the ASP.NET file from the users who access an ASP.NET Web page. ASP.NET script engine is the engine that processes the server-side scripts contained in an ASP.NET application. After processing the scripts, the engine renders the result as an HTML document and sends it back to the browser. In addition to hiding the code of the ASP.NET file from the users, ASP.NET has the following advanced features that help develop robust Web applications:  Compiled code: The code written in ASP.NET is compiled and not interpreted. This makes ASP.NET applications faster to execute than other server-side scripts, such as the scripts written in a previous version of ASP that are interpreted.  Power and flexibility: ASP.NET applications are based on CLR. As a result, the power and flexibility of the .NET platform is available to ASP.NET applications. ASP.NET applications enable you to ensure that the .NET Framework class library, messaging, and data access solutions are seamlessly accessible on the Web. ASP.NET is also language-independent. As a result, you can choose any .NET language to develop your application. Features of ASP.NET 1.10 Introducing ASP.NET NIIT  Simplicity: ASP.NET enables you to build user interfaces that separate application logic from the presentation content. In addition, CLR simplifies application development by using managed code services, such as automatic reference counting and garbage collection. Therefore, ASP.NET makes it easy to perform common tasks ranging from form submission and client authentication to website configuration and deployment.  Manageability: ASP.NET enables you to manage Web applications by storing the configuration information in an Extensible Markup Language (XML) file. You can open the XML file and modify it.  Scalability: ASP.NET has been designed with scalability in mind. It has features that help improve performance in a multiprocessor environment.  Security: ASP.NET provides a number of options for implementing security and restricting user access to a Web application. All these options are configured within the configuration file.  Extensibility: ASP.NET provides a number of options to create an extensible Web application. For example, you can create custom controls and extend the default Hypertext Transfer Protocol (HTTP) pipeline. The path through which the data flows from the client to the server is called the HTTP pipeline. It is a technique in which multiple HTTP requests are written out to a single socket without waiting for the corresponding responses. It improves the page loading time. [...]... Introducing ASP.NET 1.11 Task 1.1: Creating an ASP.NET Website Task 1.2: Opening an Existing ASP.NET Website Anatomy of an ASP.NET Application ASP.NET applications are generally divided into multiple Web pages Every Web page in an ASP.NET application shares a common set of resources and configuration settings These resources and configuration settings cannot be shared by the Web pages from any other ASP.NET. .. virtual directory on a Web server 1.12 Introducing ASP.NET NIIT The following figure shows a Web server that is hosting four Web applications A Web Server Hosting Four Web Applications Note A virtual directory is a directory that is exposed to the public on a Web server NIIT Introducing ASP.NET 1.13 Directories Used in ASP.NET Web Applications An ASP.NET application uses some specialized directories... themes that are used in the Web application Directories Used in an ASP.NET Application Some of the subdirectories given in the preceding table are created in specific applications For example, the App_Themes directory is created when you use themes in your application 1.14 Introducing ASP.NET NIIT Files Used in ASP.NET Web Applications The ASP.NET Web applications can include different types of files The... WebHandler directive Files Used in an ASP.NET Application Configuration Files Used in ASP.NET Web Applications ASP.NET uses a hierarchy of configuration files to keep application configuration settings separate from the application code A configuration file is an XML file that contains configuration settings for an application and has a config extension NIIT Introducing ASP.NET 1.15 It provides the following... Adding a New Web Form to an ASP.NET Website 1.18 Introducing ASP.NET NIIT The Page Class All Web forms are instances of the ASP.NET Page class, which is defined in the System.Web.UI namespace The Page class inherits the TemplateControl class, which, in turn, inherits the Control class As a result, the Page class provides useful events that can be used in the code Page Events ASP.NET uses an event-driven... levels, local settings will take precedence over global settings ASP.NET Web Page Code Model A Web page is made up of the following two components: The visual portion: Refers to the static HTML and ASP.NET server controls that define the layout of a Web page The programming logic: Refers to the code that is required to interact with the Web page ASP.NET provides two models for managing the visual elements... with aspx These are ASP.NET Web pages that contain the user interface and, optionally, the underlying application code Users request or navigate directly to one of these pages to start a Web application Ends with ascx These are ASP.NET user controls These controls are similar to Web pages, except that the user cannot access these files directly Instead, they must be hosted inside an ASP.NET Web page User... ASP.NET uses an event-driven model of programming This model of ASP.NET defines a sequence of events that are raised during the lifecycle of a Web page The following table lists some of the page events Event Description Init It is the first event that occurs when the server executes an ASP.NET page It occurs only once in the entire lifecycle of an ASP.NET page Load It is fired after the Init event, when the... that are used in the page Unload It represents the last event that occurs in the lifecycle of an ASP.NET page This event is used to perform final cleanup work, such as the closing of open database connections, discarding objects, or closing files Page Events and Their Description Intrinsic Objects of ASP.NET ASP.NET has a number of built-in objects that are programmed using methods, properties, and collections... properties, and collections These objects are made available to the Page object, which is an instance of the System.Web.UI.Page class from which all ASP.NET pages are inherited ASP.NET provides the following built-in objects: Application Request NIIT Introducing ASP.NET 1.19 Response Server Session HttpContext Application The Application object provides a reference to an object of the HttpApplicationState . Developing ASP. NET Applications Creating an ASP. NET Web Application 1.12 Introducing ASP. NET NIIT Task 1.1: Creating an ASP. NET Website Task 1.2: Opening an Existing ASP. NET Website ASP. NET. an ASP. NET file. Processing of a Request for an ASP. NET File W orking of an ASP. NET Application NIIT Introducing ASP. NET 1.9 N ot e The steps involved in the execution of an ASP. NET. Web. ASP. NET is also language-independent. As a result, you can choose any .NET language to develop your application. Features of ASP. NET 1.10 Introducing ASP. NET NIIT  Simplicity: ASP. NET

Ngày đăng: 12/08/2014, 17:21

TỪ KHÓA LIÊN QUAN

w