[ Pobierz całość w formacie PDF ]
.PrerequisiteBefore working on this lab, you must know how to use a component.Lab SetupThere are starter and solution files associated with this lab.The starter files arein the folder \Labs\Lab07\Starter and the solution files for thislab are in the folder \Labs\Lab07\Solution. Module 7: Creating a Microsoft ASP.NET Web Application 39ScenarioIn Exercise 1, you will use the ASP.NET cache to store a DataSet that is usedby the _menu.aspx page.When users want to sign into the conference system, they need to enter a valide-mail name and corresponding password.This is done on the login.aspx pageor through register.aspx in the case of a new user.In this lab, you will firstcomplete the login.aspx and register.aspx pages to attempt to authenticate a userthrough the use of a cookie (forms authentication).Exercises 2 and 4 involvevariations on forms authentication of this user.Exercise 3 illustrates how toretrieve the customer ID of the authenticated user from any of the pages of yourapplication.You can use this ID to store customer information or productsselected by the customer in the database.Estimated time to complete this lab: 60 minutes 40 Module 7: Creating a Microsoft ASP.NET Web ApplicationExercise 1Storing DataIn this exercise, you will programmatically cache the DataView used by theDataList control in the file _Menu.ascx.You will then look at web.config tosee how the connection string for the Conf database is stored.To read the DataView from the cache1.Open the file _Menu.ascx file in the folder InetPub\wwwRoot\ASPNET.2.At the beginning of the Page_Load event procedure, immediately after thedvMenuItems variable is declared, add code to read the contents of thedvMenuItems item from the cache and save it in the dvMenuItems variable.Your code should look like the following:dvMenuItems = Cache("dvMenuItems")3.Test the contents of dvMenuItems.If the content is empty:a.Create the DataView from the database by using the code that is alreadyin the event procedure.b.Store the DataView in the cache.Create the cache such that it will bestored for one hour.Your code should look like the following:If (dvMenuItems Is Nothing) ThenResponse.Write ("Getting items from the database.")Dim products As New Conference.ProductsDBdvMenuItems = products.GetProductCategories()._Tables(0).DefaultViewCache.Insert("dvMenuItems", dvMenuItems, Nothing, _DateTime.Now.AddHours(1), TimeSpan.Zero)ElseResponse.Write ("Got items from the cache.")End IfTo save and test your work1.Save your changes to _Menu.ascx.2.By using Internet Explorer, go to the home page of the ASPNET Web siteby viewing http://localhost/ASPNET/default.aspxThe items are retrieved from the database.3.Refresh the page in Internet Explorer.The items are retrieved from the cache. Module 7: Creating a Microsoft ASP.NET Web Application 41To investigate web.config application settingsAs you can see in the _Menu.ascx file, the GetProductCategories() method isused to get the items for the menu from the database.This method is in theProductsDB.vb component.1.Open the ProductsDB.vb file from the Components folder and locate theGetProductCategories method.The SQL connection string is obtained fromConferenceDB.ConnectionString.2.Open the ConferenceDB.vb file from the Components folder and locate theConnectionString property.The connection string is read from the DSN key in thesection of the web.config file.3.Open the web.config file in the ASPNET Web site and locate the DSN keyin the section. 42 Module 7: Creating a Microsoft ASP.NET Web ApplicationExercise 2Using Forms AuthenticationIn this exercise, you will validate the users name and password from thelogin.aspx page with information stored in the database.If the information isvalid, you will transfer the contents of the temporary shopping cart into apermanent shopping cart for the user.Next, you will create an authenticationcookie that will be used throughout the Web site.You will use two different classes in the conference component:Conference.ShoppingCartDB manipulates the shopping cart andConference.CustomersDB accesses the customer information in the Confdatabase.The source code for these classes can be found in theNote\Components\ShoppingCartDB.vb and \Components\CustomerDB.vb files inthe ASPNET Web site.You will call the following methods:Conference.ShoppingCartDB.GetShoppingCartID() returns a string withthe ID of the current shopping cart.Public Function GetShoppingCartId() As StringConference.ShoppingCartDB.MigrateCart() migrates the items from oneshopping cart (temporary) to another (permanent) [ Pobierz całość w formacie PDF ]

  • zanotowane.pl
  • doc.pisz.pl
  • pdf.pisz.pl
  • funlifepok.htw.pl
  •