1 / 31

What Makes .NET Different?

What Makes .NET Different?. Scott Mitchell. Overview. The evolution of the Web. Classic ASP overview – its strengths and weaknesses. Time for something new: an examination of Microsoft’s .NET Strategy. ASP.NET to the Rescue! Comparing and Contrasting ASP.NET and classic ASP.

solange
Télécharger la présentation

What Makes .NET Different?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What Makes .NET Different? Scott Mitchell

  2. Overview • The evolution of the Web. • Classic ASP overview – its strengths and weaknesses. • Time for something new: an examination of Microsoft’s .NET Strategy. • ASP.NET to the Rescue! • Comparing and Contrasting ASP.NET and classic ASP. • For more information…

  3. Dynamic Scripts Distributed, Compiled Programs Static Web Pages Content was static. To alter the look and feel of a Web page, a programmer had to physically alter the contents of the page itself. The static nature of the Web at this time removed any possibility of a user interacting with a Web site or interaction among Web sites. Performance was great and development easy, but the Web lacked any real usability. Dynamic scripts allowed for user interaction with a Web site. Web content could be dynamically generated based on a number of variables, such as user input. Allowed for the Web to serve as an application medium. Development was anything but easy. The scripting nature of development led to poor programming practices and “messy” code. Also, interaction among Web sites was possible, but limited and difficult. Web pages are actual, programs created using object-oriented programming techniques. These programs are compiled instead of interpreted like the scripts of the past. A focus on Inter-Web server communication allows developers to build truly distributed applications on the Web. The Evolution of the Web

  4. Classic ASP - Strengths • Low cost of entry • Quick and easy to learn for experienced developers and new developers alike. • Can create very useful Web applications in a relatively short amount of time. • An active ASP community • Many, many great classic ASP books, Web sites, training classes, and conferences.

  5. Classic ASP - Weaknesses • Script-based technology used, leading to poorer performing, less readable code than a compiled counterpart. • Encouraged developers to shamelessly intermix code (script) and content (HTML). • Difficult to debug. • Lacked modern programming features, such as try…catch exception handling, true object-orientation, etc.)

  6. “Fixing” Classic ASP • ASP.NET, as we’ll shortly see, fixes all of these problems inherent in classic ASP! • Before we look at ASP.NET, specifically, let’s first turn our attention to Microsoft’s .NET Strategy.

  7. Ready or .NET, here it comes! • In July 2000, Microsoft announced their .NET Vision at their Professional Developer Conference (PDC). • The main “components” of .NET include: • A runtime system (the Common Language Runtime, or CLR) • A large set of classes that serve as an API for program’s run through the CLR (commonly referred to as the .NET Framework classes, or the .NET SDK). • New programming languages.

  8. The CLR • Whenever a .NET program is executed, it is fed into the CLR, which executes the program. • The code expected by the CLR needs to be in a special intermediate language (MSIL, Microsoft Intermediate Language). • So, “compilers” like VB.NET turn source code into this MSIL. This MSIL code is like a high-level, architecture independent assembly language.

  9. The CLR (continued…) • When the CLR first runs a .NET program, it must convert this abstract high-level assembly language into platform-specific code (referred to as Just-In-Time (JIT) compilation). • This JITed copy can then be run by the CLR each time the program needs to be run.

  10. VB.NET Compiler VB.NET Source Code Intermediate Code JITed Your application running!!! CLR The CLR (Continued…)

  11. The .NET Framework • The .NET Framework contains a plethora of developer libraries that insulates the OS from the developer. • These libraries are broken down into hundreds of classes grouped in logical namespaces, where each namespace separates a different set of classes. • The .NET Framework is similar in concept to the Win32 API, except the .NET Framework is OO-based and sensibly arranged with helpful documentation.

  12. The .NET Framework (Continued…) ASP.NET and the inherent server controls are classes in the .NET Framework. The System.Web namespace encapsulates the classes used by ASP.NET. • This means that you can access and utilize .NET classes from within an ASP.NET page, meaning through an ASP.NET Web page you can do:  File Uploads  Image manipulations  On the fly (de|en)cryption  Systems-level activities (Event log, perf. mon., etc.)

  13. New Programming Languages • To create .NET programs, you need to use a .NET programming language (one that compiles to MSIL and uses the .NET Framework classes). Such languages include:  VB.NET  C#  JScript.NET  MS C++ .NET  Perl.NET  COBOL.NET

  14. Visual Basic .NET • VB.NET introduces many new modern concepts into VB: • Try … Catch exception handling • True OOP • Short-circuit Boolean operators, variable initialization, standard array base (0), etc. • VB.NET has a handful of “breaking” changes: • No more default properties • Set/Let support dropped • Subs require parenthesized parameters

  15. Example VB.NET Code 'Create an ArrayList Dim myArrayList as New ArrayList() myArrayList.Add("ASP.NET") myArrayList.Add("is") myArrayList.Add("cool!") Response.Write(GetRandomWord(myArrayList)) Function GetRandomWord(myAL as ArrayList) Dim rndNumber as New Random() Return myAL(rndNumber.Next(myAL.Count)) End Function

  16. C# • Microsoft’s newest language offering. • Similar to Java in syntax and semantics: • Case sensitive • Statements delimited by semicolons • Blocks delimited by curly braces • Like every .NET language, very OO.

  17. Example C# Code // Create an ArrayList ArrayList myArrayList = new ArrayList(); myArrayList.Add("ASP.NET"); myArrayList.Add("is"); myArrayList.Add("cool!"); Response.Write(GetRandomWord(myArrayList)); string GetRandomWord(ArrayList myAL) { Random rndNumber = new Random(); return myAL[rndNumber.Next(myAL.Count)]; }

  18. What Language to Use? • VB.NET and C# both rely on the classes in the .NET Framework to accomplish their tasks. • Therefore, essentially anything you can do with C#, you can do with VB.NET. • Programs written in C# and VB.NET are relatively equal in performance. • Therefore, choose the programming language that you and your team knows best!

  19. Language Interoperability • Realize that every data type (int, string, object, etc.) is defined as a class in the .NET Framework. • That means an int in C# and an Integer in VB.NET are the same thing – an instance of the Int32 class in the .NET Framework. • Since all .NET languages: • Compile to standard MSIL • Use the same data type definitions components written in one language can be used in another.

  20. ASP.NET to the Rescue! • ASP.NET solves for many of the disadvantages in classic ASP. • ASP.NET Web pages are compiled .NET programs created by modern .NET programming languages (VB.NET, C#, JScript.NET, Perl.NET, etc.) • ASP.NET provides excellent debugging options and opportunities, especially through tools like Visual Studio .NET

  21. ASP.NET to the Rescue! (Continued…) • ASP.NET encourages separation of code and content (HTML) in many ways: • The use of Code-behind pages which physically separate the code from the content. • Use of “server controls,” which provide VB-like control functionality through a Web page. (John’s talk next will address server controls in great detail!)

  22. Examining ASP.NET • ASP.NET is comprised of two major areas: ASP.NET Web pages and ASP.NET Web services. • ASP.NET Web pages are akin to classic ASP pages – Web surfers visit them through a browser and are returned valid HTML. • ASP.NET Web services provide for inter-Web server communications. This allows an ASP.NET Web page (or a stand-alone application) to access a remote program to obtain information. (More on this topic in tomorrow’s talk on Web services.)

  23. Examining ASP.NET (Continued…) ASP.NET Web pages and Web services are compiled programs. So when a user visits one of your ASP.NET Web pages, an actual “program” is being executed – the ASP.NET Web page. • These Web pages and Web services are compiled on-demand, meaning that when a Web page or Web service is first visited, it is compiled. From then on, a cached version (using disk-based caching) of the intermediate code is referenced.

  24. ASP pages output standard HTML code, thereby not requiring any specific browser. ASP.NET contains Web controls that return HTML 3.2-compliant HTML. Could use ADO to access database information. Can access databases via ADO.NET. Developers could create ASP pages quickly and easily using VBScript ASP.NET development is even quicker and easier than classic ASP and utilizes VB.NET, which is very similar to VBScript. Comparing ASP.NET and ASP Classic ASP ASP.NET

  25. Uses scripting languages (VBScript / JScript/PerlScript) Uses compiled, .NET-compatible language (VB.NET / C# / JScript.NET, etc.) Web pages contain .asp extension Web pages contain .aspx extension. HTML and server-side script intermixed. Server-side script placed in distinct SCRIPT blocks or even separate source files. Contrasting ASP.NET and ASP Classic ASP ASP.NET

  26. Getting Started with ASP.NET • Need to install the .NET Framework • Only runs on Windows 2000 and Windows XP Pro (requires that IIS 5.0+ be installed). • The .NET Framework is freely available to download from http://www.asp.net/ • Once the .NET Framework has been installed you can create ASP.NET pages simply by creating a file (using your favorite editor (Notepad / Visual Studio, etc.) with a .aspx extension in a Web directory (I.e., C:\InetPub\wwwroot\).

  27. The Good News… • ASP.NET and Classic ASP can run side-by-side on a Web server. That is, you can have ASP.NET Web pages and classic ASP pages running on your Web site. • One of .NET’s goals is to provide side-by-side functionality, meaning you should be able to run ASP.NET v2.0 and v1.0 on the same Web server at the same time (whenever ASP.NET v2.0 comes out, that is!).

  28. Getting Started with ASP.NET(Some Simple ASP.NET Web Pages Examples…) • ASP.NET Web Pages can be created to look just like classic ASP pages. Show SimpleASP.NET.demo.aspx. • Note that when we run this demo, there is a slight delay. The .NET Framework is actually running an instance of the VB.NET compiler! This delay only occurs when the page is loaded for the first time after it is created or a change to the source code has occurred. • Also note that ASP.NET Web pages output regular HTML, just like classic ASP pages.

  29. Getting Started with ASP.NET(Some Simple ASP.NET Web Pages Examples…) • ASP.NET Web pages are actual, OOP programs, consisting of a class derived from the Page class in the .NET Framework. • ASP.NET pages can be coded to handle the Page class events (the most commonly used Page class event handler you’ll create is for the Load event, which fires when an ASP.NET page is visited). • ASP.NET pages ideally will contain server-side SCRIPT blocks instead of in-line (<% … %>) script. • Show ProperASP.NET.demo.aspx

  30. Online Resources • There are a plethora of .NET Web sites: • http://aspnet.4GuysFromRolla.com • http://www.asp101.com • http://www.15Seconds.com • http://www.asp.net • http://www.aspnextgen.com • http://www.aspalliance.com • There are many newsgroups and listservs and online forums as well: • http://www.aspfriends.com • http://www.aspmessageboard.com

  31. Questions??? Now would be a great time to ask questions!

More Related