« Home « Chủ đề ASP.NET Features

Chủ đề : ASP.NET Features


Có 140+ tài liệu thuộc chủ đề "ASP.NET Features"

ASP.NET 4 Unleased - p 123

tailieu.vn

FIGURE 26.15 Retrieving a lost password with the PasswordRecovery control.. <asp:PasswordRecovery id=”PasswordRecovery1”. Runat=”server”>. Subject=”Password Reminder” />. </asp:PasswordRecovery>. After you open the page in Listing 26.34 in your web browser, you are first asked to enter your username (see Figure 26.15). Before you use the PasswordRecovery control, you must specify your mail server set- tings in your application’s web configuration file....

ASP.NET 4 Unleased - p 124

tailieu.vn

This chapter was devoted to the ASP.NET Login controls. You learned how to create both a Login and Registration page.. You learned how to use the Login control to authenticate users and the CreateUserWizard control to register new users. You learned how to display either a Login or Logout link with the LoginStatus control. You learned how to display the...

ASP.NET 4 Unleased - p 125

tailieu.vn

You can add a machineKey element with explicit keys to either the machine root web configuration file or to particular application web configuration files. If you don’t want to share the same keys across all the applications on a web server, you should add the machineKey element only to the applications that you need to share.. In the previous section,...

ASP.NET 4 Unleased - p 126

tailieu.vn

ptg 1224 CHAPTER 27 Using ASP.NET Membership. The location element enables you to apply a set of authorization rules to a folder or page at a particular path.. In that case, you can use the location element to specify the path of the single page. The web configuration file in Listing 27.13 password-protects a page named Secret.aspx. LISTING 27.13 Web.Config...

ASP.NET 4 Unleased - p 127

tailieu.vn

Make sure that you change the value of the decryptionKey attribute before using the web configuration file in Listing 27.19. You can generate a new decryptionKey with the GenerateKeys.aspx page described in the “Using Forms Authentication Across Applications” section, earlier in this chapter.. You can set three Membership provider attributes that determine password policy:. minRequiredPasswordLength —The minimum required password length....

ASP.NET 4 Unleased - p 128

tailieu.vn

ptg 1244 CHAPTER 27 Using ASP.NET Membership. You must enable this attribute when using the Web Site Administration Tool.. attributeMapPasswordQuestion —Enables you to map the Membership security ques- tion to an Active Directory attribute.. attributeMapPasswordAnswer —Enables you to map the Membership security answer to an Active Directory attribute.. attributeMapFailedPasswordAnswerCount —Enables you to map the Membership MaxInvalidPasswordAttempts property to an Active...

ASP.NET 4 Unleased - p 129

tailieu.vn

If you request the page in Listing 27.31 after enabling the WindowsTokenRoleProvider , you see the content displayed by the LoginView control only when you are a member of the Windows Administrators group.. Authorization Manager (AzMan) is a component of Windows Server 2003 and Windows Server 2008. You can use Authorization Manager to define roles, tasks, and operations.. Authorization Manager...

ASP.NET 4 Unleased - p 130

tailieu.vn

ptg Finally, we examine a feature introduced with ASP.NET 2.0 the Profile object. When a web server creates a cookie, an additional HTTP header is sent to the browser when a page is served to the browser. This Set-Cookie header causes the browser to create a cookie named message that has the value Hello. After a cookie has been created...

ASP.NET 4 Unleased - p 131

tailieu.vn

<html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>Delete Cookie</title>. <form id=”form1” runat=”server”>. <asp:Label. id=”lblCookieName”. Text=”Cookie Name:”. Runat=”server” />. <asp:TextBox. id=”txtCookieName”. <asp:Button id=”btnDelete”. Text=”Delete Cookie”. In Listing 28.5, the expiration date is set to one day ago.. The page in Listing 28.6 deletes all cookies sent from the browser to the current domain (and path).. LISTING 28.6 DeleteAllCookies.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>....

ASP.NET 4 Unleased - p 132

tailieu.vn

In Listing 28.11, a DataView object is stored in Session state. Using the Session Object. The main application programming interface for working with Session state is the HttpSessionState class. This means that you can access Session state from just about anywhere.. Count —Enables you to retrieve the number of items in Session state.. IsReadOnly —Enables you to determine whether the...

ASP.NET 4 Unleased - p 133

tailieu.vn

Don’t use the web configuration file in Listing 28.16 without modifying the values of both the decryptionKey and validationKey attributes. You can use the GenerateKeys.aspx page discussed in Chapter 27, “Using ASP.NET Membership,” to generate new values for these attributes.. After you complete these configuration steps, Session state information is stored in the ASP.NET State Server automatically. You don’t need...

ASP.NET 4 Unleased - p 134

tailieu.vn

ptg LISTING 28.23 Web.Config. <?xml version=”1.0”?>. <authentication mode=”Forms” />. <anonymousIdentification enabled=”true” />. name=”numberOfVisits”. allowAnonymous=”true” />. The numberOfVisits property defined in Listing 28.23 includes the allowAnonymous attribute. The web configuration file also enables Forms authentication. The page in Listing 28.24 illustrates how you modify a Profile property when Anonymous Identification is enabled.. LISTING 28.24 ShowAnonymousIdentification.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>....

ASP.NET 4 Unleased - p 135

tailieu.vn

<asp:Button id=”btnAdd”. Runat=”server” OnClick=”btnAdd_Click” />. If you want to take control over how complex properties are stored, you can modify the value of the serializeAs attribute associated with a Profile property. For example, the results of serializing the ShoppingCart class with the XML Serializer are contained in Listing 28.31:. LISTING 28.31 Serialized Shopping Cart. <?xml version=”1.0” encoding=”utf-16”?>. <ShoppingCart xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>....

ASP.NET 4 Unleased - p 136

tailieu.vn

LISTING 28.40 ManageProfiles.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>. lblProfiles.Text. lblInactiveProfiles.Text. FIGURE 28.10 Deleting inactive profiles.. lblResults.Text = String.Format(“{0} Profiles deleted. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. id=”lblProfiles”. Runat=”server” />. id=”lblInactiveProfiles”. <asp:Button id=”btnDelete”. Runat=”server” OnClick=”btnDelete_Click” />. id=”lblResults”. The page in Listing 28.40 displays the total number of profiles and the total number of inactive profiles. The web...

ASP.NET 4 Unleased - p 137

tailieu.vn

Using Page Output Caching . T he slowest operation that you can perform in an ASP.NET page is database access. By taking advantage of caching, you can cache your data- base records in memory. Page Output Caching . Page Output Caching enables you to cache the entire rendered contents of a page in memory (everything that you see when you...

ASP.NET 4 Unleased - p 138

tailieu.vn

<asp:Button id=”btnSelect”. Runat=”server” />. <asp:GridView id=”grdMovies”. <asp:SqlDataSource id=”srcCategories”. ConnectionString=”<. <asp:SqlDataSource id=”srcMovies”. Runat=”server”>. <asp:ControlParameter Name=”CategoryId”. ControlID=”dropCategories” />. </asp:SqlDataSource>. The page in Listing 29.4 contains an <. The ID of the DropDownList control is assigned to this parameter.. The VaryByControl attribute causes different cached versions of the page to be created whenever the DropDownList represents a different value.. Another option is to...

ASP.NET 4 Unleased - p 139

tailieu.vn

DateTime.Now.ToString(“T”) %>. Runat=”server” />. ConnectionString=”<. <a href=”AddMovie.aspx”>Add Movie</a>. The page in Listing 29.12 contains a DetailsView control that enables you to add a new movie. Response.RemoveOutputCacheItem() method is called to remove the MovieList.aspx page from the cache. LISTING 29.12 AddMovie.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>. HttpResponse.RemoveOutputCacheItem(Page.ResolveUrl(“~/MovieList.aspx”));. Response.Redirect(“~/MovieList.aspx”);. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. Runat=”server” OnItemInserted=”dtlMovie_ItemInserted”>. HeaderText=”Title:”...

ASP.NET 4 Unleased - p 140

tailieu.vn

ptg LISTING 29.19 ShowWriteSubstitution.aspx. Page Language=”C#” %>. OutputCache Duration=”15” VaryByParam=”none” %>. “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. DateTime.Now.ToString(“T”) %>. First, the method referenced by the WriteSubstitution() method does not have to be a method of the current class. The second advantage of the WriteSubstitution() method is that you can use it within a custom...

ASP.NET 4 Unleased - p 141

tailieu.vn

LISTING 29.26 ShowDynamicUserControl.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. (PartialCachingControl)Page.LoadControl(“Movies.ascx”);. FIGURE 29.10 Programmatically caching a User Control.. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <title>Show Dynamic User Control</title>. <form id=”form1” runat=”server”>. id=”lblCacheDuration”. Runat=”server” />. <asp:PlaceHolder id=”PlaceHolder1”. In Listing 29.26, the default cache duration is modified by modifying the. You can refer to the User Control contained with an instance of the....

ASP.NET 4 Unleased - p 142

tailieu.vn

LISTING 29.32 DataSourceKeyDependency.aspx. Page Language=”C#” %>. “http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd”>. <script runat=”server”>. <html xmlns=”http://www.w3.org/1999/xhtml” >. <head id=”Head1” runat=”server”>. <form id=”form1” runat=”server”>. Runat=”server” />. ConnectionString=”<. <a href=”AddMovieDataSourceKeyDependency.aspx”>Add Movie</a>. The SqlDataSource control in Listing 29.32 includes a CacheKeyDependency property that has the value MovieKey . This property creates a dependency between the DataSource control’s cached data and an item in the cache named MovieKey. The...