惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
F
Fortinet All Blogs
B
Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Microsoft Security Blog
Microsoft Security Blog
Blog — PlanetScale
Blog — PlanetScale
月光博客
月光博客
腾讯CDC
小众软件
小众软件
G
Google Developers Blog
V
Visual Studio Blog
罗磊的独立博客
GbyAI
GbyAI
V
V2EX
大猫的无限游戏
大猫的无限游戏
H
Help Net Security
L
LangChain Blog
Engineering at Meta
Engineering at Meta
量子位
The GitHub Blog
The GitHub Blog
博客园 - 司徒正美
WordPress大学
WordPress大学
B
Blog RSS Feed

博客园 - Koven

如何拓展你的人脉关系 所谓职业(转载) 期待已久的一本电子书出来了:Applying Domain-Driven Design and Patterns: With Examples in C# and .NET 搜索引擎相关站点收集(转载) 中文搜索引擎系统架构(转载) 中文搜索引擎网络蜘蛛(转载) 中文搜索引擎中的排序技术(转载) 中文分词介绍(转载) 转载一篇不错的关于.NET中内存使用的文章 Data Type Performance Tuning Tips for Microsoft SQL Server(转载) 怎么在ASP.NET 2.0中使用Membership (转载) HttpModule 示例(转载) ASP.NET服务器控件与组件基础概念——HttpHandler (转载) ASP.NET服务器控件与组件基础概念——HttpModule(转载) Best practices for .Net Performance - I HTTP运行期与页面执行模型(转载) XML格式的网站配置文件常见读写方案比较(转载) ASP.NET应用中十大常见的潜在问题(转载) 微软研发75条心得(转载)
Tips to improve the performance of ASP.Net Application
Koven · 2006-08-08 · via 博客园 - Koven

1. Disable the Debug Mode or Set Debug ="false"

How it affect performance: By default this attribute is "true" when you create new application and is useful when you are developing the application. Debug = true means that pdb information to be inserted into file and this results a larger file size and it's performance issue. Before deployment you should set the following tag

 <compilation defaultLanguage="C#" debug="false">

2. Set trace enabled="false"

 
How it affects performance: With help of tracing, we can track the application's and the sequences. Enabling tracing adds performance overhead and might expose private information, so it should be enabled only while an application is being actively analyzed. You can turn off tracing using 
 
<Trace enabled="false" - - - - -/>

3. While developing using Visual Studio.NET

When you set Configurations Option as "debug" mode, it creates pdb file to store the debug information hence before deploying the application set it to the "Release" mode.

You can set using

Select Menu Build -> Configuration Manager -- > Set the configuration option of project to the "Release" mode.

4. Disable the viewstate:

With the help of automatic state management feature, the server control is re-populate their values without writing any code. And it affects the performance. The always set EnableViewState = false when not requires.

For control
<asp: datagrid EnableViewState="false" datasource="..." runat="server"/>
For Page
<%@ Page EnableViewState="false" %>


5. Use Caching to improve the performance of your application.

OutputCaching enables your page to be cached for specific duration and can be made invalid based on various parameters that can be specified. The Cache exists for the duration you specify and until that time, the requests do not go to the server and are served from the Cache.

Do not assign cached items a short expiration. Items that expire quickly cause unnecessary turnover in the cache and frequently cause more work for cleanup code and the garbage collector. In case you have static as well as dynamic sections of your page, try to use Partial Caching (Fragment Caching) by breaking up your page into user controls and specify Caching for only those Controls which are more-or-less static.

6. Use appropriate Authentication Mechanism.


Following are the Authentication Modes.

  • None
  • Windows
  • Forms
  • Passport

7. Validate all Input received from the Users.

Validate all Input received from the users at client side to avoid the server round trip.

8. Use Finally Method to kill resources.

Always use the finally block to kill resources like closing database connection, closing files etc.

9. Always use the String builder to concatenate string

The memory representation of string is an array of characters, So on re-assigning the new array of Char is formed & the start address is changed. Thus keeping the old string in memory for garbage collector to be disposed. Hence application is slow down. Always use the string builder for concatenating string.

10. Enable the web gardening for multiprocessors computers:

The ASP.NET process model helps enable scalability on multiprocessor machines by distributing the work to several processes, one for each CPU, each with processor affinity set to its CPU. The technique is called Web gardening, and can dramatically improve the performance of some applications

11. Set Enlist="false" in connection string:

True indicates that the SQL Server connection Pooler automatically enlists the connection in the creation thread's current transaction context. That's why set enlist = false in connection string.

12. Avoid recursive functions / nested loops


13. Always set option strict to "on"

14. Try to avoid Throwing Exceptions.