原文链接:http://scottwater.com/blog/archive/asp-net-web-config-tips-part-two/
1.当发布产品时设置debug = "false"
<compilation defaultLanguage="c#" debug="false" />
debug为true的缺点是编译页面时间更长,代码执行时间更长,运行时使用更多的内存
2.如果你不能管理产品运行的环境 将程序信任级别设为medium
<trust level = "Medium" />
因为越来越多的ISP将asp.net的信任级别设为Medium.在这个信任级别,有不少事情是做不到的.
3.如果不用session,则禁用session state
<sessionState mode="Off" />
否则在每次Request中就包含session信息.
4.Disable ViewState
<pages enableViewState="false" />
5.定义自定义控件 这样在每个页面中都可以直接使用
<pages>
<controls>
<add tagPrefix="csControl" namespace="CommunityServer.Controls" assembly="CommunityServer.Controls"/>
</controls>
</pages>
6.定义用户控件
<pages>
<controls>
<add tagPrefix="monroe" tagName="PostView" src="~/controls/postsview.ascx"/>
</controls>
</pages>
7.使用配置源(configSource)属性
<connectionStrings configSource="connectionStrings.config" />
8.使用ASHX代替HttpHandlers
<%@ WebHandler Language="C#" Class="CommunityServer.Blogs.Components.WeblogRssHandler" %>
若是像处理Rss或图片,用途单一,就适合使用ashx