1 / 32

Build Web Applications with Visual Studio ® .NET

Build Web Applications with Visual Studio ® .NET. Carlotta Eaton – www.nr.vccs.edu/eaton Associate Professor of IST New River Community College Slides by Microsoft Modified by Carlotta Eaton. Agenda. Web Forms ASP.NET Applications Caching. Session Prerequisites.

rune
Télécharger la présentation

Build Web Applications with Visual Studio ® .NET

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. Build Web Applications with Visual Studio® .NET Carlotta Eaton – www.nr.vccs.edu/eaton Associate Professor of IST New River Community College Slides by Microsoft Modified by Carlotta Eaton

  2. Agenda • Web Forms • ASP.NET Applications • Caching

  3. Session Prerequisites • Experience with Visual Basic® 6.0, Visual Basic .NET, Visual C#™or Visual C++®, Visual Basic Scripting Edition • Experience developing Web Applications Level 200

  4. Agenda • Web Forms • ASP.NET Applications • Caching

  5. Web FormsActive Server Pages .NET • Part of the .NET Framework • ASP.NET builds, deploys, and runs Web applications and services • Visual Studio .NET Web applications support ASP.NET directly VB C++ C# Perl Python … Web Services User Interface ASP.NET ADO.NET: Data and XML Base Framework Common Language Runtime

  6. Web Forms ASP.NET Page Framework • New control-based, event-driven execution model for Web UI • “Visual Basic for the Web” • Much less code required than ASP • Cleanly encapsulated functionality • Executed via CLR as native code • Visual Basic, C#, JScript® • ASP.NET pages use “.ASPX” extension • Runs side-by-side on Internet Information Server with current ASP applications

  7. Web Forms Part Declarative, Part Code • A Web Form combines declarative tags (HTML, ASP directives, server controls and static text) with code • However, good separation provided between code and tags Visual Studio .NET single file separate files <tags> <tags> code code Form1.aspx Form1.aspx Form1.vb

  8. Web Forms Page Event Life Cycle Page is loaded and initialized Page_Load Control Events Textbox1_Changed 1. Change Events Button1_Click 2. Action Events Page_Unload Page is disposed

  9. Web FormsServer Controls • 45 Built In Controls • Target any HTML 3.2 browser • Raise Events to Server • Basic Controls • textbox, checkbox, radio, button • Advanced Controls • AdRotator, Calendar, DataGrid, Validator

  10. Web Forms Server Controls • Declared as HTML or XML tag with runat=server attribute • Examples:<input type=text id=text2runat=server> <asp:calendar id=myCal runat=server/> • Tag name identifies control to create • Control is implemented as .NET object • ID attribute provides programmatic accessor

  11. Web FormsBasic Server Controls • <asp:textbox id=text1 runat=server/>text1.text = “Hello World” • <asp:checkbox id=check1 runat=server/>check1.checked=True • <asp:button id=button1 runat=server/>onclick=button1_onClick() • <asp:DropDownList id=DropDownList1 runat=server>DropDownList1.SelectedItem.Text = “Hello”

  12. Web FormsServer Side Events • <asp:button id=Button1 runat=server • onClick=Button1_Click> • <asp:DropDownList id=DrpDwn1 runat=server OnSelectedIndexChanged=DrpDwn1_ItemSelected>

  13. Agenda • Web Forms • ASP.NET Applications • Caching

  14. ASP.NET ApplicationsSaving Application State • Essentially global variables for the application • Application(“CompanyName”) • Can lock or unlock Application State Variables • Application.lock • Application(“GlobalCounter”) = NewValue • Application.unlock

  15. ASP.NET ApplicationsSaving Session State • Per User Variables • Available to All Pages in the Site • Session(“UserID”) = 5 • UserID = Session(“UserID”)

  16. ASP.NET ApplicationsASP versus ASP.NET State • ASP Session State • Forces “Server Affinity” • Dependent on cookies • Not fault tolerant • ASP.NET Session State • Support for Web Gardens and Server Farms • Doesn’t require cookies • Better fault tolerance

  17. ASP.NET ApplicationsConfiguring Session State • Configuration information stored in Web.Config <sessionState mode=“sqlserver” cookieless=“false” timeout=“20” sqlConnectionString=“data source=127.0.0.1;user id=sa;password=“” stateConnectionString="tcpip=127.0.0.1:42424" /> </sessionState>

  18. ASP.NET ApplicationsConfiguring Session State • Mode • InProc – Conventional session variables. Stored in-memory on the web server • StateServer – Sessions are stored on an external server, in memory • SqlServer – Sessions are stored in a SQL database • Cookieless • Determines if Cookieless sessions should be used • Values are true or false • TimeOut • Determines the default timeout for the web site

  19. ASP.NET ApplicationsConfiguring Session State • sqlConnectionString • contains the datasource, userid, and password parameters necessary to connect to a sql database that holds the session state • connectionString • Contains information needed to connect to the state server

  20. ASP.NET ApplicationsStoring Data in SQL Server™ • In order to setup the SQL Server to store state information you must run a small T-SQL script on the target server • InstallSQLState.sql can be found in [sysdrive]\winnt\Microsoft.NET\Framework\[version] • Creates the following on the server • A database called ASPState • Stored Procedures • Tables in TempDB to hold session data. • Uninstall is via • UninstallSQLState.sql

  21. Agenda • Web Forms • ASP.NET Applications • Caching

  22. CachingPage Output Caching • Pages That Don’t Change Frequently • Dramatic Performance Increase <%@ OutputCache Duration= "500“ VaryByParam=“none” %>

  23. Caching Fragment Caching • Dynamic Portions of a Page • Data Doesn’t Change Frequently • User Control Site Header <%@ OutputCache Duration=“60“ VaryByParm=“none” %> Navigation Page Body Caches only the page body for the specified duration

  24. Caching Cache APIs • Programmatically Cache Data Cache.Insert( _ Key, _ Value, _ CacheDependency, _ AbsoluteExpiration, _ SlidingExpiration, _ Priority, _ PriorityDecay, _ Callback)

  25. Caching Cache APIs • Key • String used to look up the cached item • Value • Item or object to store in the cache • CacheDependency • Cache item can automatically expire when a file, directory, or other cache item changes

  26. Caching Cache APIs • AbsoluteExpiration • Cache item can expire at some fixed time (midnight, for example) • SlidingExpiration • Cache item can expire after a certain amount of inactivity • Priority • When forcing items from the cache, which items should go first • PriorityDecay • Within a given priority range, does this item expire fast or slow

  27. Session Summary • Visual Studio .NET + ASP.NET = “Visual Basic for the Web” • Drag-drop-double-click • Event-driven, control-based encapsulation • Target any client, or specific clients • Big runtime benefits over ASP: • Fast native code execution • Hassle-free deployment • “Baked-in” support for security, Web Farms, out-of-proc Session state, etc.

  28. For More Information… • MSDN Web site at • msdn.microsoft.com • Microsoft® Official Curricula (MOC) • Introduction to ASP.NET • Course 2063 • Programming the .NET Framework with Visual Basic • Course 2415 • Microsoft Press® • Introducing Microsoft .NET

  29. MSDNEssential Resources for Developers Subscription Services Library, Professional, Universal Delivered via CD-ROM, DVD, Web OnlineInformation MSDN Online, MSDN Flash Training & Events MSDN Training, Tech-Ed, PDC, Developer Days, MSDN/Onsite Events Print Publications MSDN Magazine MSDN News MembershipPrograms MSDN User Groups

  30. Web Forms Demonstration #1

  31. Questions And Answers

More Related