ASP Legacy of the 20 great habits _asp.net

Source: Internet
Author: User
In the process of technological renewal, there are still some people who die clinging to something that is already too angry. There are some people who enter the new world, but still can not get rid of the old habits. I didn't use the word "bad habits" because I was also very disgusted with the word.
New technology should have the practice of new technology, into the ASP.net world, it should be used to correct the past, new into the New World, the ASP's junk thrown away.
The following are the wrong things to do, please do not be mistaken for the recommended practice to promote:

1. Use server side include to introduce a common page composition to aspx.
Under the asp.net mechanism, you should use ASCX (Web user control) 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. Is the core part of an application. But many people's web.config are often empty. Or have never been modified.

3. Use Response.Write to output messages to the front end
Asp. NET platform of response and ASP response is very different. Although it represents the same meaning, it is already very different in usage. The Response.Write content is output only to the front end of the page. The correct way to output messages to the front end is to use placeholder.

4. Manage user connection status using a series of sessions
This approach is misused in the ASP. In a asp.net environment, the right thing to do is to design a class. Save the data in a structured way. Encapsulates access to session or cookie.

5. Use Session to verify identity
It's almost a common problem. Asp. NET provides a set of APIs for user authentication. Type is forms validation or Windows authentication. This quick start has a very clear section to explain. Most people can still rely on assigning a value to the session to maintain the user authentication status.

6. Use the Response.Redirect redirect page
This can be used when necessary. But not abused. The misuse of redirects has proved to be a logical cause of serious confusion. This is the practice of using the page as the program unit. Using the front controller mode will bring the user's operational logic together]

7. Use too many ASPX pages
In ASP environment, the program unit is only *.asp page, ASP. NET is not like this, there are back-end class library, ascx and so on. You should focus your business logic on separate units instead of using an ASPX for an operation. More often, ASPX manages page logic as a container for ascx or custom control. 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
Reuse. Reuse. Reuse. The principle of dealing with such problems is that no process of the same or similar kind occurs. If you use the above method, the result will be catastrophic once there is a major logical change.

9. Fear of using a dataset.
Many people were terrified by the dataset. Think "affirmative" affects performance. But not even the first attempt. They always think that their products must be important and that they should be "cautious" in design. They often use ArrayList or design low-level classes to save collection data. Hard data is poured into the work.

10. Pay too much attention to "performance".
The mechanism of ASP.net viewstate is particularly dissatisfied. or always try to persecute others. Instead of making himself very tired. It may be more civilized to pay more attention to a few databases while dealing with ViewState.

11. The application root directory is messy.
Asp. NET is a development project. Not a Web site. Different resources should be placed in categories. For example, all static resources (style sheets, scripts, images) are 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? You should put them in another project.

12. The process of writing access to the database
The work should be handed over to dataaccess application block. You have to switch connection, why bother.

13. What you write is most reliable.
The opposite is often true. Pay more attention to the use of products written by others. And don't charge you money, why so face-saving?

14. Randomly naming aspx file names
This is the most painful. The ASPX file name is not only easy to identify. You should also follow certain rules. Because behind each aspx has a class with the same name, imagine how hard it would be. In addition, most people do not know the name space for managing their own projects. It's like seeing a ledger.

15. Never be inherited or derived
Some classes that have the same behavior should derive from the common base class. In practical sense, our aspx should have a base class pagebase. Because there are always some common features that need to be abstracted out.

16.0 Property
Their class (the ASPX corresponds to) is only private method. Do not disclose any of their secrets. This must be the survival of Java.

17.0 ascx
Needless to say, he hasn't learned to asp.net.

18. Use Dreamweaver to "draw" ASPX
This group of people are artists. There are even people who are very intoxicated to discuss how to better "consolidate" Dreamweaver and visual Studio.

19. Only familiar with System.Web.UI.WebControl and System.Data.SqlClient there should be some familiar class libraries.

20.0 Notes
These are very clear in the heart of the quick. The default annotation generated by one IDE is horizontal there regardless.

21.0 Events
Ignorant of "event-driven". Only know to write the process in Page_Load (). or double-click a button to write the Xxx_clock () process. Event and delegate are not seen in their programs.

The above is to think of where to write, if you encounter the things that you detest, can also be supplemented. I always thought that work is the most direct reflection of character. For programmers, code is the most authentic portrayal of the mind. Just a personal opinion.


Related Article

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.