ASP. NET development should abandon ASP old practices and poor practices

Source: Internet
Author: User

There is no error in using ASP, as long as the application is sufficient. However, ASP. when developing a website or system, you should discard the habit of developing ASP. NET method, instead of ASP. NET.

In the process of technological updates, there are still some people holding things that have passed through the air, and some people entering the new world, but I still cannot get rid of old habits. I didn't use the word "bad habits" because I am also very disgusted with this word.

New technologies should adopt new technologies to enter the ASP. NET world, so we should correct our past habits, enter the new world completely, and discard ASP.

The following lists all incorrect practices. do not promote them by mistake as recommended:

1. Use Server Side Include to introduce a common page diagram to ASPX.

Use ASCX (web user control) to implement ASP. NET. ASCX provides more controllable interfaces, and more importantly, ASCX is a class that can be fully controlled by a real class.

2. Do not use web. config

Web. config provides rich configuration management interfaces and is the core of an application. However, many people's web. config is usually empty or never modified.

3. Use Response. Write to output messages to the front-end

The Response on the ASP. NET platform is very different from that on ASP. NET. Although it indicates the same meaning, its usage is already quite different. The content of Response. Write will only be output to the front-end of the page. The correct way to output messages to the front-end 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 method should be to design a class, save data in a structured manner, and encapsulate access to sessions or cookies.

5. Use Session to verify the identity

This is almost a common problem, ASP.. NET provides a set of APIS for user authentication. The types are forms authentication or windows authentication. This quick start section provides a clear explanation, however, most people still rely on assigning values to sessions to maintain the user identity authentication status.

6. Use the Response. Redirect page

This can be used when necessary, but cannot be abused. It turns out that misuse of redirection will cause serious logical confusion. This is what we do when page is a program unit, use the front controller mode to centralize user operation logic.

7. Use too many ASPX pages

The program units in the ASP environment only have *. asp pages. ASP. NET is not like this. There are also back-end class libraries, ASCX and so on. The business logic should be concentrated in different units, instead of using An ASPX for one operation. In more cases, ASPX manages the logic in the page as the ASCX or custom control container. ASPX reuse ASCX and ASPX also serves as a unified page diagram.

8. Copy the code among multiple logical units and modify the corresponding Logic

Reuse! Reuse! Reuse! The principle of dealing with such problems is that there is no same or similar process. If you use the above method, once a major logical change occurs, the results will be disastrous.

9. Fear of using DataSet

Many people are frightened by DataSet and think "yes" affects performance. However, they did not even dare to make the initial attempt. They always thought that their products must be important and should be "careful" in design ". They often use ArrayList or low-level classes to save set data and perform difficult data import.

10. pay too much attention to "performance"

I am not very satisfied with the ASP. NET ViewState mechanism, or I am always eager to target others. Instead, I am tired of myself. If I have to pay more attention to connecting the database several times while dealing with ViewState, it may be more civilized.

11. The root directory of the application is messy.

ASP. NET is a development project, not a website. Different resource types should be placed. For example, to organize all static resources (style sheets, scripts, images) together, or even write a set of APIs to manage them, ASPX should be put together, and ASCX should be put together ,*. what about cs? Put them in another project.

12. Never bother writing the database access process

This should be handed over to DataAccess Application Block. Why do you need to switch the connection?

13. What you write is the most reliable

The fact is often the opposite. If you pay more attention to using products written by others, you will not be charged for it. Why do you love your face?

14. randomly named ASPX file names

This is the most painful thing. ASPX file names should not only be easy to recognize, but also follow certain rules, because every behind ASPX has a class with the same name. Imagine how uncomfortable it is. In addition, most people do not know how to manage the name space of their own projects, which makes people look like a ledger.

15. never inherit or derive

Some classes with the same behavior should be derived from the public base class. In actual sense, our ASPX should have a base class PageBase, because there are always some common features that need to be abstracted.

16. Zero property

Their classes (corresponding to ASPX) only have private methods and do not disclose any of their own secrets. This must be the legacy of JAVA.

17. Zero ASCX

Needless to say, he hasn't learned ASP. NET yet.

18. use DreamWeaver to "Draw" ASPX

This group of artists were even excited about how to better "integrate" DreamWeaver and Visual Studio.

19. Be familiar with only System. Web. UI. WebControl and System. Data. SqlClient. There should be some well-known class libraries.

20. Zero comments

These are all easy-to-understand notes generated by an IDE.

21. Zero event

I don't know anything about "event-driven". I only know the write process in Page_Load (), or double-click a button to write Xxx_Clock (). I don't know the event and delegate in their programs.

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.