Performance Tips and Tricks in .NET Applications(三

Use Session State Only If You Need To
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 To
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 across 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 should read more about View State on the 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 essentially share a single thread for interop. This results in a massive performance hit, and should 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

时间: 2024-08-01 16:51:38

Performance Tips and Tricks in .NET Applications(三的相关文章

Performance Tips and Tricks in .NET Applications(一

Performance Tips and Tricks in .NET ApplicationsA .NET Developer Platform White PaperEmmanuel SchanzerMicrosoft CorporationAugust 2001Summary: This article is for developers who want to tweak their applications for optimal performance in the managed

Performance Tips and Tricks in .NET Applications(四

Use Binary Compare for TextWhen comparing text, use binary compare instead of text compare. At run time, the overhead is much lighter for binary. Minimize the Use of Format()When you can, use toString() instead of format(). In most cases, it will pro

Android 6.0 Marshmallow tips and tricks 棉花糖的技巧和窍门

Since you're reading these lines, chances are you're among the lucky 2 percent of Android users who happen to have Marshmallow running on their smartphone. You've either received an update to Android 6.0, or you're simply a Nexus user.从你看到这个起,你很幸运的了解

(转) How to Train a GAN? Tips and tricks to make GANs work

  How to Train a GAN? Tips and tricks to make GANs work 转自:https://github.com/soumith/ganhacks    While research in Generative Adversarial Networks (GANs) continues to improve the fundamental stability of these models, we use a bunch of tricks to tra

ASP.NET AJAX Advance Tips &amp;amp; Tricks(11) 三种方法动态创建Tooltip

前言 如何动态创建提示框(Tooltip)是ASP.NET Forum里的常见问题之一,在做技术支持时,我曾在英文 博客上总结过ASP.NET和ASP.NET AJAX环境下如何动态创建提示框的三种常见方法,比较基础,收到了蛮 多老外们的commend,如今英文博客被墙,特转到这里来与大家分享. 原文地址: http://lancezhang.wordpress.com/2008/12/04/create-tooltip-dynamically/ http://lancezhang.wordpr

ASP.NET AJAX Advance Tips &amp;amp; Tricks (4)

ASP.NET AJAX Performance Improvement Preface I think everyone would agree that AJAX is one of the elements of "Web 2.0", every web developers should know this technology. I have been collected a list of the popular AJAX Frameworks on my chinese

ASP.NET AJAX Advance Tips &amp;amp; Tricks (10)

解决使用AJAX Extender时的页面导出(Word/Excel)问题 前言: 有客户问到这么个问题:我们可以使用Response容易地将ASP.NET页面导出为Excel或Word.然而,如 果有AJAX Control Toolkit的Extender在页面上的话,则会发生错误(Extender control 'XXX' is not a registered extender control).我搜索了一下,ASP.NET forum里有很多这样的问题未能解决,故写了 这个解决方案,

ASP.NET AJAX Advance Tips &amp;amp; Tricks (9)

DropDownList在Firefox下的奇怪现象和解决方案--谁的BUG? 前言: 今天在ASP.NET Forum里面遇到了一个及其怪异的问题,一个看似非常简单的demo在IE及其它浏览器中 正常运行,然而在Firefox中却导致了奇怪的问题,使页面中的DropDownList死掉,经过研究,终于找到 了一个解决方案,但此问题是谁的Bug仍不得而知. 问题重现: 一个ScriptManager 一个DropDownList 一个UpdatePanel,内有一个Button 在按钮点击事件中

ASP.NET AJAX Advance Tips &amp;amp; Tricks (8) 扩展AJAX Control Toolkit中的控件

需求: TabContainer容器中的TabPanel类本身就包含了Enabled属性,也可以使用JavaScript方法 set_enabled(X)来设置Enabled属性,如果某个TabPanel的这个属性为false的话,这个TabPanel就不会显 示在TabContainer中,这与一般控件的"Enabled"属性不太一样,我认为叫它"Visiable"会更加恰当 .如下图所示: 有时候这并不符合我们的需求,所以,在本例中,我们将为其添加Disable