Three web.config problems found in building system framework

Source: Internet
Author: User
Tags character set comments config garbage collection insert interface string access
Web| Issue--------------------------------< Special statement, this document is reproduced, Mr Huang Yong blog article >-----------------------------------
Three web.config problems found in building system framework

According to Microsoft's Duwamish7 to build a web system framework, although said to be a ready-made framework beside, but still encountered some annoying little problems, of which several of them are the web.config!
1. Set up the system frame run error, reported what can not correctly read ApplicationConfiguration configuration section, but my configuration section is entirely from the Duwamish7 copy come, and yesterday was good ah? Also do not remember how long, tried how many times they also feel that the impossible method, are no work to return. Finally, looking at it in a daze, helpless, a thought flashed: ApplicationConfiguration? Not too much. Change into Appcofiguration, try again, God! It's a success! Dizzy!
<configSections>
<section name= "appconfiguration" type= "AVWeb.SystemFramework.ApplicationConfiguration, avweb.systemframework"/ >
</< span>configsections>
2. It is also the run Web.config an error in the comment line, as follows:
--Database type 0--access 1--sqlserver-->
Because I'm not familiar with this, and it took a long time to know:<!----> contains comments that cannot contain the "--" character
3. To invoke a calendar control written by JavaScript on the page, there are Chinese comments, the JS file included in the page, but a run, how can not normal load, always reported "not end of the string constant" and so on, after a half-day, after a long time to understand is the character set to do the ghost!
The set of characters configured in the Web.config file is very important, which is this: <globalization responseencoding= "gb2312" requestencoding= "gb2312"/>
If the program has Chinese, but encoding is not gb2312 words, may be a lot of inexplicable problems come!
Duwamish7 Learning Notes (II.)
Systemframework Project
A systemframework project is a project that can be ported directly to another program, and can be used without modification or with little modification of the code.
The project is mainly 3 classes.
1.ApplicationConfiguration class
This class is an application-level configuration class that implements the IConfigurationSectionHandler interface. Similar to the previous Duwamishconfiguration class implementation method. The Main method is create (), Onapplicationstart (), readsetting ().
If you want to use this class, you need to invoke the Applicationconfiguration.onapplicationstart (context) in the Global.asax Application_OnStart event;
public static void Onapplicationstart (String myapppath)
{
AppRoot = Myapppath;
System.Configuration.ConfigurationSettings.GetConfig ("ApplicationConfiguration");
System.Configuration.ConfigurationSettings.GetConfig ("Duwamishconfiguration");
System.Configuration.ConfigurationSettings.GetConfig ("Sourceviewer");
}
This method invokes the Configurationsettingis.getconfig () method by calling the corresponding create () method by obtaining the corresponding parsing class in web.config. If no corresponding configuration resolution class is available, the System.Configuration.NameValueSectionHandler class parsing can be invoked directly, GetConfig ("Sourceviewer").
2.ApplicationAssert class
This class is designed to help developers with error checking, logging, and more. The main check (), Checkcondition (), Generatestacktrace () Three methods and LineNumber properties.
[ConditionalAttribute ("DEBUG")] applies to check () and the Generatestacktrace () method, which can be invoked if the DEBUG constant is defined.
3.ApplicationLog class
This class is primarily used to log records.
Define error (1), Warning (2), Info (3), Verbose (4) Four TraceLevel level log debug and trace information. is defined specifically in the configuration section of the web.config. All methods in this class are static methods and are the primary static void Writelog (Level,messagetext)
If the write TraceLevel is not greater than the level defined in the configuration, the corresponding debug, trace information is written to the Windows event log and the defined trace file at the defined level.
The constructor for the Applicationlog class is declared private and initializes the configuration information from the configuration file when the Applicationlog class is first invoked.

Questions:
1. In the static Applicationlog () the use of System.Threading.Monitor to ensure the security of multithreaded operations. Why is the lock control for Applicationlog?
2. The understanding of certain classes in the System.Diagnostics namespace is not clear.
MSDN Help:
1.Monitor class
Ms-help://ms. Msdnqtr.2003feb.2052/cpref/html/frlrfsystemthreadingmonitorclasstopic.htm
2.system.diagnostics namespaces (provides a specific class that enables you to interact with system processes, event logs, and performance counters)
Ms-help://ms. Msdnqtr.2003feb.2052/cpref/html/frlrfsystemdiagnostics.htm
Posted on Friday, December, 11:27 AM
Duwamish7 Learning Notes (III.)
DataAccess Project
DataAccess Project has a total of 4 categories: books, Categories class, Customers class, orders class. The IDisposable interface is implemented. Used to close the active database connection.
This is a Dispose mode that is promoted by MS to release unmanaged resources. About the Dispose mode. NET Framework Program Design (revision) of the 19 chapter "Automatic Memory Management (garbage collection)" has a brilliant exposition.
The select,insert,update operation of 4 business objects is encapsulated by invoking a stored procedure in a class.
The select operation is returned to the caller by filling the corresponding business entity class that inherits from the dataset through the SqlDataAdapter fill method. The books and categories classes have only select operations.
The INSERT and UPDATE operation returns the InsertCommand or UpdateCommand object through a private function. The external public function calls the private internal function to complete the operation. The Insert,update,select operation is implemented in the Customers class, and the Orders class has only insert operations.
There is a checkcondition () method call to the Applicationassert class in the LoadCustomerByEmail () method of the Customers class
Applicationassert.checkcondition (data. Tables[customerdata.customers_table]. Rows.Count <= 1, "Integrity Failure:non-unique e-mail Address", applicationassert.linenumber);
Questions:
1. The data access layer realizes the content of the business logic layer, usually such as LoadCustomerByEmail () and other methods are written in the business logic layer.
2. Is it necessary to abstract a completely base class for database operations to implement the underlying operations of the database? Rather than in each class such as: Books,customers are rewritten again and again such as SqlCommand objects, dispose mode?
Duwamish7 Learning Notes (IV.)
BusinessRules Project
1.Customer class
Have a look! In the Duwamish7 Learning notes (iii), you are still thinking about what the business logic layer is writing.
Check, or check! Each row, each column, including the type and length, think about the verification of the project itself, really a bit embarrassed!
//----------------------------------------------------------------
Function Validate:
Validates and customer
Returns:
True if validation is successful
False if invalid fields exist
Parameters:
[in] customerrow:customerdata to be validated
[out] customerrow:returns customer data. If there are fields
//



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.