In the process of technological upgrading, there are still some people who cling to outdated things. There are also some people who have entered the new world, but still cannot get rid of old habits. I did not use the word "bad habits". Because I am also very disgusted with this word.
New technologies should have new technology practices. When entering the world of ASP.NET, you should correct your past habits and enter a new world.
The following are all wrong practices. Please Don't mistakenly promote it as a recommended practice:
1. Use server side include to introduce common page composition to ASPX.
Under the ASP.NET mechanism, ASCX (web user control) should be used to implement it. ASCX provides more controllable interfaces. And more importantly, ASCX is a class. A real class. It can be fully controlled .
2. Do not use web.config
web.config provides a very rich configuration management interface. It is the core part of an application. However, many people's web.config is often empty or has never been modified.
3. Use Response.Write to output messages to the front end The Response under the ASP.NET platform is very different from the ASP Response. Although it means the same meaning, the usage is very different. The content of Response.Write will only be output to the front end of the page. The correct way to output the message to the front end is The method is to use PlaceHolder.
4. Use a series of sessions to manage user connection status. This method is abused in ASP. In the ASP.NET environment, the correct approach should be to design a class. Save the data in a structured way. It will be useful for sessions or Encapsulate cookie access.
5. Use session to verify identity. This is almost a common problem. ASP.NET provides a set of APIs for user authentication. The type is forms verification or windows verification. There is a section on quick start that explains this very well. Clearly, most people still rely on assigning values to sessions to maintain user authentication status.
6. Use Response.Redirect to redirect the page. This can be used when necessary, but cannot be abused. Facts have proved that abusing redirects will lead to logical Serious confusion. This is what you do when pages are used as program units. Using the front controller mode will centralize the user's operation logic]
7. Use too many ASPX pages. The program units in the ASP environment are only *.asp pages, ASP This is not the case with .NET. There are also back-end class libraries, ASCX, etc. Business logic should be concentrated in different units, instead of using one ASPX for one operation. More often, ASPX will be used as ASCX or custom control. The container manages the logic within the page. While ASPX reuses ASCX, ASPX is also reused as a unified page composition.
8. Copy code between multiple logical units and modify the corresponding logic for reuse. Reuse. Reuse. Principles for dealing with such problems There is no identical or similar process. If you use the above method, once major logic changes occur, the results will be catastrophic.
9. Afraid of using DataSet.
Many people are frightened by DataSet. They think it "definitely" affects performance. But they don't even dare to try it for the first time. They always think that their products must be important and should be "cautious" in design. They often use ArrayList or design low-level classes. Save collection data. Do the hard work of dumping data.
10. Pay too much attention to "performance".
I am particularly dissatisfied with the mechanism of ASP.NET ViewState. Or I always try my best to persecute others. On the contrary, I make myself very tired. It may be more civilized if I pay more attention to connecting to the database less frequently when dealing with ViewState.
11. The application root directory is very chaos.
ASP.NET is a development project, not a website. Different resources should be classified and placed. For example, all static resources (style sheets, scripts, images) should be organized together. You can even write a set of APIs to manage them. ASPX should be put together . ASCX should be put together. What about .*.cs? They should be put into another project.
12. If you take the trouble to write the process of accessing the database, you should leave this work to the DataAccess Application Block. You have to switch the connection on and off yourself, why bother? 13.
What you write is the most reliable.
The truth is often just the opposite. Pay more attention to using products written by others. They don't charge you money, so why bother so much about saving face.
14. Randomly naming ASPX file names is the most painful thing. ASPX file names not only need to be easy to identify. Certain rules should be followed. Because behind every ASPX will have a class with the same name, imagine how uncomfortable it is. In addition, most people do not know the name space of their own projects. It makes people look like they are looking at a ledger.
15. Never Instead of inheriting or deriving some classes with the same behavior, they should be derived from a common base class. In a practical sense, our ASPX should have a base class PageBase. Because there are always some public features that need to be abstracted.
16. Zero property
There are only private methods in their classes (corresponding to ASPX). They do not disclose any of their secrets. It must be the work of JAVA veterans.
17. Zero ASCX
Needless to say, he hasn’t learned ASP.NET yet
18. Use DreamWeaver to “draw” ASPX
This group of people are artists. Some people are even very intoxicated in discussing how to better "integrate" DreamWeaver and Visual Studio.
19. If you are only familiar with System.Web.UI.WebControl and System.Data.SqlClient, there should be some others worth familiarizing with. Class library.
20.Zero Annotations These are fast players who know very well. The default comments generated by any IDE are ignored.
21.Zero Events knows nothing about "event-driven". It only knows that in Page_Load() Write a procedure. Or double-click a button to write the Xxx_Clock() procedure. Events and delegates cannot be seen in their programs.