DUWAMISH7 study notes (six)

xiaoxiao2021-03-06  48

Web project

The web project is a business display layer of the DUWAMISH system, providing customers with access interfaces to the application.

1.pagebase.cs is the base class of each page, mainly to obtain the URL information of the page, gets or sets Customer and Cart information from the session, and renovates the onlineRROR () event of Web.ui.page. Capture page error, call ApplicationLog.WriteError () method Write the log.

2.ModualBase.cs Inherits from UserControl, and features the session to save Customer and CAT information.

3. The method and attributes of all shopping carts are encapsulated in the Cart.cs class. The CART class implements serialization and deserialization of the iSerializable interface to the ORDERDATA object.

4. DEFAULT.ASPX page There is no specific number of code, just a combination of controls. Default.aspx page enablesessionState = TRUE

5. ENABLEVIEWSTATE of all controls in BannerModule.ascx is set to false, but it can also be directly set directly on the control. EnableViewState = FALSE, the user control is not

EnableessionsState properties. The balnermodule data is almost rarely changed, so the cache is enabled, add the code at the top of the control:

"

<%

...

@ OutputCache Duration = "3600" VarybyParam = "none" VarybyControl = "bannermodule.pathprefix"

%>

"Duration indicates that the cache time is 60 minutes. VaryByParam =" none "indicates that the output cache is changed without the parameter value, and VarybyControl indicates the PathPrefix for each request.

Perform an output cache. Note: If you use the VaryByControl property in the instruction, you don't need to include the VaryByParam property.

6.SearchModule.ascx is used to make a book query module, the code is very simple, the code of the relocation is very beautiful :)

Response.Redirect

New

StringBuilder (PageBase.urlbase)) .append (

"

/SearchResults.aspx?type=

"

) .Append (index) .append (

"

& fullttype =

"

) .Append (server.htmlencode (searchdropdownlist.items [index] .text)) .append (

"

& text =

"

) .Append (server.urlencode (searchtext)). TOSTRING (),

False

);

On such a series of string, there is a SRINGBUILDER, and there is the call to the server.htmlencode (), a server.urlencode () method, reducing unnecessary trouble.

7.SearchResult.aspx: Query results display page. Because the query page does not use the Customer and Order information, the enableessionState of the page is set to false, and the enableViewState is also set to FLASE.

Get incoming parameters in the Page_Load () event, generate query results. Some code is as follows:

IF

(Ispostback)

{/// Avoid a Refresh Problem if The user has left the search // string empty by rerunning last search. // IF ((TextBox) Modulesearch.FindControl ("SearchTextBox")). Text.trim ()! = String.empty) {Return;}}

//

Other code

Can you directly put the Other Code into if (! Ispostback) {} "Avoid A Refresh Problem"?

8. CategoriesModule.ascx: Category Information Show module, because Categories information rarely changes, save the classification information obtained in the database to cache, set

The failure time is 60 minutes.

9.accountModule.ascx: Create or edit user accounts, creating or editing customers save in Session, facilitating and quickly getting and updating.

Creating a new customer information The password has passed through the layer encryption.

a. The user's password is consistent with the confirmation password.

b. Calculate the hash value of the password via sha1.comutehash

c. The resulting hash value is re-generated with the RNGCryptoServiceProvider to generate a length of 4 encrypted random numbers to generate a new byte array.

d. The new byte array calculates the new hash value and

e. Add the original encrypted random number again to get the encrypted password saved in the database.

Login

a. Get the user's email hash

b. Access the user to the database to encrypt the password

c. Get the original 4-bit random additive value

d. Generally, re-entered the current user input email hash value for hash calculation

e. The resulting hash value is compared with the encrypted password saved in the database.

Hash Note: The hash function is the foundation of the modern cryptographic system. These functions map any length of binary string to a small binary string (called hash value).

The encrypted hash function has such an attribute: it is impossible to calculate two different inputs through the hash algorithm. The hash function is usually used in digital signatures and maintaining data integrity.

The hash value is used as a unique value indicating a fixed size of a large amount of data. If the corresponding data matches, the hash of the two datasets should match.

A small number of data for data will generate unpredictable changes in a hash value.

10.ViewSourceModule.ascx: View the user control of the source code. There is also the relevant viewsource.aspx page and not included in the project.

The DOCS folder and each page or the extension of the extension called .src file, to implement the implementation code of the program running when the program is running.

ViewSourceModule user controls also enable the cache declaration as follows:

"

<%

...

@ OutputCache Duration = "3600" VarybyParam = "none" VarybyControl = "bannermodule.pathprefix"

%>

"

MSDN Help:

1. Page cache and user control cache

ms-help: //MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconcachingmultipleversionsofpageorcontroloutput.htmms-help: //MS.MSDNQTR.2003FEB.2052/cpguide/html/cpconcachingmultipleversionsofusercontroloutput.htm

2. PageBase base class and modulebase base class have been used for sessions, why not use cache? What are the differences and their respective advantages?

Doubt: 1. When the query is redirected, server.htmlencode () and server.htmlencode () and server.urlencode (), what is the difference between the two coding methods? Can you use Urlencode () here?

2. The contents of the page display are made by HTMLENCODE () encoding.

3. Data for EnablePageCache configuration in applications in DailyPickModule.ascx

IF

DUWAMISHCONFIGURATION.ENABLEPAGECACHE

{// Enable Page Caching ... Response.Cache.SetExpires (DateTime.Now.AddSeconds (DuwamishConfiguration.PageCacheExpiresInSeconds)); Response.Cache.SetCacheability (HttpCacheability.Public);}

I don't understand, in bannermodule.ascx, categoriesmodule.ascx has the operation of cache, why don't you need to make judgments in these two places?

In addition, there is no impact on the Enable or Disable page Cache information in BannerModule and CategoriesModule? ?

转载请注明原文地址:https://www.9cbs.com/read-77493.html

New Post(0)