Performance Tips and Tricks in. NET Applications (3

Source: Internet
Author: User

Use Session State Only If You Need
One extremely powerful feature of ASP. NET is its ability to store session state for users, such as a shopping cart on an e-commerce site or a browser history. since this is on by default, you pay the cost in memory even if you don't use it. if you're not using Session State, turn it off and save yourself the overhead by adding <@ % EnabledSessionState = false %> to your asp. this comes with several other options, which are explained at the ASP.. NET Web site.
For pages that only read session state, you can choose EnabledSessionState = readonly. this carries less overhead than full read/write session state, and is useful when you need only part of the functionality and don't want to pay for the write capabilities. use View State Only If You Need
An example of View State might be a long form that users must fill out: if they click Back in their browser and then return, the form will remain filled. when this functionality isn' t used, this state eats up memory and performance. perhaps the largest performance drain here is that a round-trip signal must be sent guest ss the network each time the page is loaded to update and verify the cache. since it is on by default, you will need to specify that you do not want to use View State with <@ % EnabledViewState = false %>. you shoshould read more about View State on the ASP. NET Web site to learn about some of the other options and settings to which you have access. avoid STA COM
Apartment COM is designed to deal with threading in unmanaged environments. there are two kinds of Apartment COM: single-threaded and multithreaded. mta com is designed to handle multithreading, whereas sta com relies on the messaging system to serialize thread requests. the managed world is free-threaded, and using Single Threaded Apartment COM requires that all unmanaged threads essential share a single thread for interop. this results in a massive performance hit, and shoshould be avoided whenever possible. if you can't port the Apartment COM object to the managed world, use <@ % AspCompat = "true" %> for pages that use them. for a more detailed explanation of sta com, see the MSDN Library. batch Compile

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.