890 likes | 1.05k Views
Chapter Objectives. Web Applications (Page 464). Web application Group of files and folders (including virtual folders) located in Web applications root directory Virtual Web and directories Stored outside of the C:Inetpubwwwroot folder Internet Information Services Management Tools
E N D
Chapter Objectives Introduction to ASP.NET, Second Edition
Web Applications (Page 464) • Web application • Group of files and folders (including virtual folders) located in Web applications root directory • Virtual Web and directories • Stored outside of the C:\Inetpub\wwwroot\ folder • Internet Information Services Management Tools • Create Chapter9 project and import files • Microsoft Management Console (MMC) • %systemroot%\System32\inetserv\iis.mmc Introduction to ASP.NET, Second Edition
The Internet Information Services Management Tools Introduction to ASP.NET, Second Edition
The Internet Information Services Management Tools (continued) Introduction to ASP.NET, Second Edition
Web Application Memory Models Introduction to ASP.NET, Second Edition
Web Application Memory Models (continued) • Create Chapter9High process • Configure to run in isolated process • IIS MMC – Directory tab, change Application Protection property to High(Isolated) • Use Component Services • %systemroot%\system32\Com\comexp.msc Introduction to ASP.NET, Second Edition
Web Application Memory Models(continued, Page 468) Introduction to ASP.NET, Second Edition
Web Application Memory Models (continued) Introduction to ASP.NET, Second Edition
Session Data • User information tracked across user sessions • HTTP headers - ServerVariables collection • SessionID - identifies each session • Read Session ID, ServerVariables, store data Dim SID As String = Session.SessionID Session("UserAgent") = Request.UserAgent.ToString Session("SID") = SID Dim strName As String = txtName.Text Session("username") = strName Introduction to ASP.NET, Second Edition
SessionGetVariables.aspx (Page 471) Introduction to ASP.NET, Second Edition
Session Data (continued) Introduction to ASP.NET, Second Edition
Building Information Management Security Policies • Security Policies • Sample – encode forms to prevent entering <> Dim strName As String strName = txtName.ToString message.Text = "Welcome " & HTTPUtility.Encode(strName) • Privacy Policies • Inform user about information being collected and what is being done with that information Introduction to ASP.NET, Second Edition
Application Configuration • Registry - Windows applications store configuration settings • Metabase stored Web application configuration • To access the Metabase • Microsoft Management Console (MMC) – local application • Windows Scripting Host (WSH) - creates scripts to access the Metabase • ASP.NET configuration files Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages(Page 477) • Web Site Tab • IP address and Port • HTTP Keep-Alives Enabled - maintain state • W3C Extended Log File Format • Extended properties • Default location - %WinDir%\System32\LogFiles • Default directory - is W3SVC1 • Log filename - is named after the date • Local time Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) • Documents tab • Default document name • Document Footer • HTTP Headers tab • Expire page content • Internet Content Rating Association (ICRA) • Home Directory tab • Web site location • Properties – Read, Write, Directory browsing, Log visits property, Index this resource, Script source, Execute, Scripts only • Configuration Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) Introduction to ASP.NET, Second Edition
Viewing the Web Server Property Pages (continued) Introduction to ASP.NET, Second Edition
Application Configuration Files • XML-based • Machine-level - machine.config • Application - Web.config • settings configured as a node, include nested child nodes • Root node - <configuration> • ConfigSections node - identify configuration sections • system.web - Web configuration settings Introduction to ASP.NET, Second Edition
The AppSettings Configuration Node • Key/value pairs - application variables <appSettings> <add key="SN" value="Tara Store" /> </appSettings> • Retrieve dim SN as string SN = ConfigurationSetttings.AppSettings("SN") Introduction to ASP.NET, Second Edition
The Pages Configuration Node • How content is delivered to the Web page • Buffer - area in memory on the server • enableSessionState - use Session • enableViewState - store data in ViewState • enableViewStateMac - validate data in ViewState • autoEventWireup - override Page_OnLoad event • SmartNavigation - continue at the row where they left off when they refresh the page Introduction to ASP.NET, Second Edition
The httpRuntime Configuration Node • Properties: • executionTimeout - time allowed to execute before the request times out • maxRequestLength - kilobytes accepted from an HTTP request • UseFullyQualifiedRedirectURL - fully qualify the URL when the client has been redirected to a new page Introduction to ASP.NET, Second Edition
Globalization Configuration Node • Encoding standard • Unicode - each character set has its own identity • Default value is UTF-8 • All Unicode character values are supported • Culture and uiCulture • Can set at page level, to configure language & dates • Identify a language and culture string • fr-FR for French • en-US for United States English Introduction to ASP.NET, Second Edition
Setting the Culture Property France.aspx (Page 489) Introduction to ASP.NET, Second Edition
Compilation Node Configuration • Language compilers build applications • DefaultLanguage property • Can set at page level <%@ Page Language="vb" %> • Explicit - declare your variables • Strict - declare the variable data type <compilation debug="false" explicit="true" defaultLanguage="vb" > </compilation> Introduction to ASP.NET, Second Edition
Trace Node Configuration • Properties • enabled - turn tracing on • localOnly - results displayed at http://localhost/. • traceMode - sort trace results • pageOutput - display results with Web page • trace stack – stores data • requestLimit - number of trace results stored Introduction to ASP.NET, Second Edition
Trace Node Configuration (continued) • Trace.Write • Trace.Write – writes data to trace stack • Trace.Warn shows up in red font • Trace.Write("CategoryName", "Value") • TraceTool • http://localhost/approot/Trace.axd • http://localhost/Configuration/Tracing/TraceTool/trace.axd Introduction to ASP.NET, Second Edition
Trace Node Configuration (continued) Introduction to ASP.NET, Second Edition
Using the Trace Utility Program Trace.aspx (Page 493) • Change Web.config <trace enabled="true" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true" /> Introduction to ASP.NET, Second Edition
Trace.aspx (continued) Introduction to ASP.NET, Second Edition
Trace.aspx (continued) Introduction to ASP.NET, Second Edition
Trace.aspx (continued) Introduction to ASP.NET, Second Edition
CustomErrors Node Configuration • Both ASP.NET and IIS provide error pages • IIS Web pages - c:\winnt\Help\iisHelp\common\ directory • MMC - configure custom error pages • HTTP status message code - status of request • 200 - success • 404 - file requested could not be found • 400’s usually indicate a client-related error • 500’s usually indicate a server-related error Introduction to ASP.NET, Second Edition
CustomErrors Node Configuration (continued) • Properties: • Mode – where to display rich error pages (yellow) • RemoteOnly - only locally • On - custom error pages except at localhost • Off - ASP.NET error pages displayed • defaultRedirect property - sets a default error page if no custom error page is configured • errornode – uses statusCode to redirect user Introduction to ASP.NET, Second Edition
CustomErrors Node Configuration (continued) <customErrors mode="RemoteOnly" defaultRedirect="/defaultError.aspx"/> <error statusCode="404" redirect="/error404.aspx"/> </customErrors> Introduction to ASP.NET, Second Edition
CustomErrors Node Configuration (continued) Introduction to ASP.NET, Second Edition
Maintaining State in an ASP.NET Application • Methods - unique identifier to recognize the client across Web pages: • ViewState – with hidden fields • Client-Side Cookies - • ASP.NET uses Application and Session objects • Cookieless applications – identification data is passed with the URL. Introduction to ASP.NET, Second Edition
Client-Side Cookies • Small piece of information stored on client • Cookies collection - group of cookies • Sent by the server through the header • Browser writes the cookie <script language="JavaScript"> document.cookie = "CookieEmail=kkalatatarastore.com; expires =Monday, 07-Jan-07 12:00:00 GMT"; readCookie = document.cookie; </script> Introduction to ASP.NET, Second Edition
Client-Side Cookies (continued) Introduction to ASP.NET, Second Edition
Client-Side Cookies ClientCookies.aspx (Page 499) Introduction to ASP.NET, Second Edition
Cookie Settings in the Internet Explorer Browser Introduction to ASP.NET, Second Edition
Cookie Settings in the Internet Explorer Browser (continued) Introduction to ASP.NET, Second Edition
Cookie Settings in the Internet Explorer Browser (continued) Introduction to ASP.NET, Second Edition
Creating Cookies with ASP.NET • HTTP cookies - created by the Web server • SessionID - value of the HTTP cookie • Retrieve using server variable HTTP_COOKIE <% Request.ServerVariables("HTTP_COOKIE") %> • Response.Cookies • Sends cookie to browser in Set-Cookie header • Named group of cookies - dictionary cookie • Individual cookies - cookie keys Introduction to ASP.NET, Second Edition
Creating Cookies with ASP.NET (continued) • Create cookie <% Response.Cookies("myCookie") = "value" %> <% Response.Cookies("myCookie").Expires = "MM DD, YYYY" %> • Read cookie <% Request.Cookies("myCookie")%> Introduction to ASP.NET, Second Edition
Maintaining State with Cookies Cookies.aspx (Page 505) Introduction to ASP.NET, Second Edition
Cookies.aspx (continued) Introduction to ASP.NET, Second Edition