Giáo trình Giới thiệu Ms.NET và SAP.NET - Nguyễn Hà Giang
Bạn đang xem 20 trang mẫu của tài liệu "Giáo trình Giới thiệu Ms.NET và SAP.NET - Nguyễn Hà Giang", để tải tài liệu gốc về máy bạn click vào nút DOWNLOAD ở trên
Tài liệu đính kèm:
giao_trinh_gioi_thieu_ms_net_va_sap_net_nguyen_ha_giang.ppt
Nội dung text: Giáo trình Giới thiệu Ms.NET và SAP.NET - Nguyễn Hà Giang
- Trình bày: ThS Nguyễn Hà Giang
- MS. NET Framework & C# Nền tảng MS .NET Framework Ngôn ngữ chính của .NET: C# ASP.NET Tổng quan về công nghệ ASP.NET Lịch sử phát triển Đặc tính cơ bản 6/24/2021 2
- 6/24/2021 3
- Chương trình nền tảng cho cho công nghệ XML Web Web Windows .NET Service Forms Forms ASP.NET Cung cấp tập hợp class C# VB.NET J# C++ library thường dùng Custom Classes Quản lý sự thực thi của Data and XML Classes các chương trình .NET Base Framework Classes Common Language Runtime 6/24/2021 4
- 6/24/2021 Nguyen Ha Giang 5
- .NET 3.5 (Nov-2007) VS.NET 2008 Default: Windows 7 .NET 2.0 (Nov-2005) VS.NET 2005 .NET 3.0 (Nov-2006) Default: Windows Vista, Server 2008 .NET 1.1 (Apr-2003) VS .NET 2003 Default: Server 2003 6/24/2021 6
- Common Language Infrastructure (CLI) Provide a language- neutral platform for application development and execution 6/24/2021 7
- Chạy trên nền (.NET Framework) Mã nguồn được biên dịch qua MSIL MSIL được thông dịch qua mã máy lúc thực thi nhờ vào CLR Độc lập nền tảng Về lý thuyết có thể chạy trên mọi nền! 6/24/2021 8
- CT C# C#.NET Compiler Programmer CT VB .NET VB.NET Compiler MS IL CLR CT J# .NET J#.NET Compiler C++ CT Compiler C++.NET 6/24/2021 9
- Theo quan điểm của người lập trình, .NET có thể hiểu như môi trường thực thi mới và thư viện lớp cơ sở cải tiến. Môi trường thực thi là: Common Language Runtime - CLR Vai trò chính CLR: locate, load, manage .NET types CLR còn quản lý những phần ở mức thấp như: memory management, security check 6/24/2021 10
- Common Type System (CTS): Mục đích hỗ trợ thực thi chéo ngôn ngữ Định nghĩa kiểu DL tiền định và có sẵn trong IL: Tất cả ngôn ngữ .NET sẽ được sinh ra mã cuối trên cơ sở kiểu dữ liệu này! VB.NET C# IL Integer int Int32 6/24/2021 11
- Intermediate Language Abstracted assembly language Ý tưởng về mã Java byte Mã cấp thấp cú pháp đơn giản quá trình dịch sang mã máy nhanh hơn! CLR chuyển IL thành mã máy lúc runtime Sự chuyển này gọi là Just – In – Time Compilation hay JIT compiling 6/24/2021 12
- Source .NET Code Assembly Compiler csc.exe or vbc.exe C++, C#, VB or DLL or EXE any .NET language 6/24/2021 13
- Managed Modules Chứa IL code để thực thi Chứa resource, metadata Portable Executable (PE) Process assembly (EXE) Library assembly (DLL) 6/24/2021 14
- Ứng dụng được viết để sử dụng trong .NET Framework UD khác thì gọi là Unmanaged code “Managed”: do chạy dưới sự giám sát của cơ chế thực thi (CLR) Legacy Software Managed Executable (unmanaged code) Common Language Runtime Windows (OS khác) 6/24/2021 Nguyen Ha Giang - 2009 15
- class myClass{ Managed Heap void Method(){ variable v1; variable v2; B A do{ . C E } D } A và D sẽ bị xoá do ko còn tham chiếu hay truy cập tới 6/24/2021 16
- GC xuất hiện không định trước, do CRL gọi. GC thực hiện việc tìm kiếm những đối tượng trong managed heap, xoá nếu ko còn tham chiếu tới. Có thể gọi GC một cách tường minh 6/24/2021 17
- Tránh xung đột tên Namespace CS1 Cho phép phân cấp Class A Truy cập đầy đủ qua tên Class B Tất cả data type có tiếp đầu ngữ là tên namespace Class C Namespace CS2 Class A Class B CS1.A Class C CS2.A 6/24/2021 18
- Hầu hết các lớp cơ sở chung của .NET đều thuộc namespace System Lớp CS Array thuộc System → System.Array .NET đề nghị tất cả kiểu do user định nghĩa phải nằm trong 1 namespace Tên CompanyName namespace Customer Tên lớp Personel 6/24/2021 19
- Nên phân thành 2 cấp: Công nghệ Gói phần mềm chức năng CompanyName SaleServices Customer Tên namespace Tên lớp ManagingServices Personel 6/24/2021 20
- Thư viện lớp cơ sở .NET là managed code Được xây dựng từ ngôn ngữ C#! Khá đa dạng & đầy đủ: Cho phép kế thừa để phát triển UD Bao bọc tất cả các hàm API Dễ sử dụng (khác với VC++ trước đây) 6/24/2021 21
- Các lớp .NET bao gồm các vấn đề Đặc tính lõi cung cấp IL, kiểu dữ liệu trong CTS Hỗ trợ Win GUI và control WebForm (ASP.NET) Data Access (ADO.NET) Directory Access File System, registry access Networking and web browsing .NET attributes and reflection WinOS access COM interoperability 6/24/2021 22
- Thư viện nền tảng cho .NET Framework Chia làm 2 phần: base class library và framework class library Namespace Description System Chứa lớp toán học, chuyển đổi dữ liệu System.IO Các lớp cho thao tác Input và Output System.Net Các lớp liên quan đến network protocol System.Collections Chức các lớp liên quan đến xử lý tập hợp System.Data Các lớp của ADO.NET System.Drawing Các lớp thực thi chức năng GUI System.Threading Các lớp lập trình MultiThread System.Web Các lớp liên quan đến HTTP protocol System.Xml Các lớp liên quan XML System.Web.UI Cung cấp lớp và interface để tạo ASP.NET Server System.Web.UI. WebControls Control và ASP.NET web pages 6/24/2021 23
- 6/24/2021 24
- ASP (Active Server Page) Server side scripting Các file chứa HTML và scripting code Truy cập thông qua HTTP Scripting code được interpreting ở server side ASP cho phép Nhanh chóng và dễ dàng tạo ứng dụng Web Khởi tạo nội dung web động Validation script ở phía client Sử dụng COM với chức năng mở rộng: truy cập DB 6/24/2021 25
- Trộn lẫn giữa layout (HTML) và phần logic (script) Interpreting ASP dẫn đến hạn chế thực thi Ngôn ngữ script không mạnh về kiểu dl JScript, VBScript Tương thích với trình duyệt Quản lý trạng thái kém Cập nhật file khi server down 6/24/2021 26
- Nền tảng phát triển web mới của MS Mô hình lập trình server –side mới Web Client IIS ASP.NET Applications .NET Framework Operating System 6/24/2021 27
- Tách bạch giữa layout và business logic Sử dụng các dịch vụ được cung cấp bởi .NET Code được compile lần đầu tiên khi page được request Quản lý trạng thái Sử dụng nhiều ngôn ngữ lập trình Cross language integration Cập nhật file trong khi server running! 6/24/2021 28
- Namespace Cấu trúc được phân cấp Dot-syntax, những lớp được nhóm lại một cách logic Nhiều lớp trừu tượng cơ sở và đa dạng các lớp thực thi Cho phép lập trình viện thoải mái sử dụng & cũng như tạo riêng cho mình các lớp Ví dụ: System.Web.UI.WebControls. Button Namespace Class 6/24/2021 29
- System.Object System.Web.UI.Control System.Web.UI. WebControl WebControls ListControl Table ListBox Button CheckBoxList TextBox 6/24/2021 30
- Cú pháp ASP.NET và các ngôn ngữ hỗ trợ Tiến trình thực thi Assemblies Quản lý trạng thái, bảo mật và xử lý sự kiện 6/24/2021 31
- Layout và Business logic Không còn trộn lẫn giữa HTML và scripting code Dễ dàng maintainance cho Web app Phân biệt hoàn toàn giữa phần layout và phần xử lý logic Không chứa code thực thi trong những file HTML Chia ra các file dành cho thiết kế & các file dành cho lập trình .aspx.cs Có thể trộn lẫn code và layout nếu muốn! .aspx 6/24/2021 32
- Visual Basic VBScript is unmanaged ! JScript C# New component-based language C++ Managed Extensions for C++ Others: Cobol, Smalltalk, Common Language Specification (CLS) 6/24/2021 33
- Các loại file phân biệt với tên phần mở rộng File ASP.NET chuẩn: aspx, ascx Web service: asmx Code (behind) file: .aspx.cs, .asmx.vb File cấu hình: Web.config Web applications: global.asax, global.asax.cs Tất cả file đều là dạng file text Cách dễ dàng để bắt đầu từ file asp chuyển thành aspx 6/24/2021 34
- Directives Code Declaration Blocks [ lines of code ] Code Render Blocks HTML Control Syntax 6/24/2021 35
- Custom Control Syntax Custom server controls Server control property Subproperty Server control event binding 6/24/2021 36
- Data Binding Expression ’ runat=“server” /> Server-side Object Tags Server-side Include Directives Server-side Comments 6/24/2021 37
- void SubmitBtn_Click(object sender, EventArgs e) { Message.Text = "Hello " + Name.Text; } Name: 6/24/2021 38
- 6/24/2021 39
- Client Server IIS Request .aspx file ASP.NET Runtime Code Parse .aspx file behind Generate page class Instantiate controls Response 6/24/2021 40
- Compile khi trang được request lần đầu tiên MS intermediate language (MSIL) Dạng ngôn ngữ trừu tượng Độc lập CPU MSIL được thực thi bởi CLR Common Language Runtime Just-in-Time compiler Managed code 6/24/2021 41
- Kết quả của quá trình biên dịch là file *.exe/*.dll Một hoặc nhiều assemblies Assembly 1 MyApp.dll pic1.jpg metadata 6/24/2021 42
- Application State What is an “application”? Files, pages, modules, and executable code One virtual directory and its subdirectories Application state variables Global information Implementation rules Use of system resources “Lock” and “unlock” your global information Beware of global variables in multithreaded environments Loss of state when host is “destroyed” No state sharing across Web farms 6/24/2021 43
- Session State What is a session? Restricted to a logical application Context in which a user communicates with a server Functionality Request identification and classification Store data across multiple requests Session events Release of session data .NET State Server Process 6/24/2021 44
- Reasons for Security Prevent access to areas of your Web server Record and store secure relevant user data Security Configuration in Web.Config , , , Authentication, Authorization, Impersonation Code Access Security Are you the code you told me you are? Protect your server from bad code 6/24/2021 45
- Authentication Validates user credentials Awards an authenticated identity Types of authentication Windows, integrating with IIS 5.0 Passport, centralized services provided by Microsoft Forms, request attachment Authorization Determine whether request is permitted File and URL authorization 6/24/2021 46
- Impersonation IIS authenticates the “user” A token is passed to the ASP.NET application ASP.NET impersonates the given token Access is permitted according to NTFS settings Code Access Security .NET Framework feature Verify the code‘s identity and where it comes from Specify operations the code is allowed to perform 6/24/2021 47
- Application-level Event Handling Web Forms Delegate Model Connect event sender and event receiver Single and multicast delegates Event Delegates Are Multicast Event Wiring Register event handler with event sender 6/24/2021 48
- Events raised on client, but handled on server event Web Client message Server parse message event call appropriate event handler event handler response 6/24/2021 49
- Giải quyết được các hạn chế của ASP 1. Enhanced performance 2. Power and flexibility 3. Simplicity 4. Manageability 5. Scalability and availability 6. Customizability and extensibility 7. Reliability 8. Security 6/24/2021 50
- Make it easier to build web apps Make it easier to deploy web apps Make it easier to operate web apps Provide greater performance, reliability, and scalability 6/24/2021 51



