Asp.net optimization series (3)

Source: Internet
Author: User
Asp.net optimization discussion series (3) I would like to say that I may not have any experience in organizing this series. After all, this is my first attempt to summarize a small series and I hope to have a good start, so after some consideration, I bravely posted the homepage. (Fortunately, Dudu is not so fast to remove) Haha, I still remember that when I first went to the garden Article It is really difficult to understand a large part. After all, there must be a certain foundation, so sometimes it is easier to simply write articles! Pai_^
Okay, hold on, continue to summarize!

Code details Optimization

Data Access : First, the database connection is very resource-consuming. Of course, we have a data connection pool, and the operation database connection will not really access the database to establish a connection. However, you must know that the number of connections is limited, so we should try to open the connection later and close it as soon as possible! Code
1 Using (Sqlconnection con = New Sqlconnection ())
2 {< br> 3 sqlcommand CMD = New sqlcommand ( " select * from Table " , con);
4 .
5 con. open ();
6 cmd. executenonquery ();
7 con. close ();
8 }

Instead of placing con. open (); In Front Of The ellipsis.
Let's take a look at the above sentence "select * from table". It is really nice to write this sentence. We can simply query the data, but we have returned all the fields, A large amount of data increases the pressure on the database.
Encoding:
1. Are you still trying? This item will also lose some performance. During encoding, We will generally anticipate the errors that will be produced in the encoding part. You can use it.CodeTo solve the problem, so free of charge!
2. Now there are generics, which are much more efficient than the original non-generic ones, avoiding the performance loss of packing and unpacking!
3. string connection: a large number of string connections. It must be better to use stringbuilder than to use string. This is the reason why a temporary string is generated during string connection, memory consumption!

Server Optimization

Distributed: Generally, we deploy the business logic and data access layers on the same server, so all the pressure is concentrated on this server. Even if it is strong, it is too tight, it's hard to bear! OK. Now that we have WCF and Web Service and remoting, we have a lot of options to create a web service and place business logic or data access in it, then deploy it on another server. In this way, the call between servers reduces the pressure!
Static Resources: Images and audio files. If they are deployed on other servers, will the stress be reduced? At least there will be fewer request files on the display layer! Haha

Page Structure (somewhat digress)

JS loading : Because the page is first displayed, you should put it at the end of the page, or you can use Dom, or dynamic loading on the server!
CSS : separates the style from the structure. Needless to say, the page is very clean and the style is uniform, some people even like to classify styles into CSS files such as basic styles, layout styles, and content styles. However, I like to combine them into two versions, one of which is compressed, one is uncompressed to facilitate future modification! This reduces the number of requests and facilitates maintenance!

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.