asp.net性能
1.关闭不必要的Session
<%@ Page EnableSessionState="flase"%>
2.关闭不必要的ViewState
<asp:DataGrid EnableViewState="false" runat="server">
如果页面级
<%@ Page EnableViewState="false"%>
3.不要使用Exception控制程序流程
Exception是很耗资源的
4.禁用VB和JScript动态数据类型
动态数据类型是要占用大量的CPU运行时间
<%@ Page Language="VB" Strict="true"%>
5.使用存储过程的数据访问
6.只读数据访问不要使用DataSet(DataSet是断开连接的,存储再内存中,所以资源的消耗巨大)
使用SqlDataReader代替DataSet
SqlDataReader是read-only,forward-only
7.关闭ASP.NET的Debug模式,部署时是再web.config中取消Debug.
8.ASP.NET输出缓冲
页面缓冲:
<% OutputCache Duration=60 VaryByParam="None"%>
Duration=延迟时间;
VaryByParam=控件id,例如VaryParam="TextBox1";
切不可作无为的缓冲;
片断缓冲 :VaryByControl
asp.net新的对象Cache于Application对象具有相同的作用域
Cache.Insert("MyData",Source,new CacheDependency(Server.MapPath("authors.xml")));
绝对过期
Cache.Insert("MyData",Source,null,DataTime.Now.AddHours(1),TimeSpan.Zero);
相对过期
Cache.Insert("Mydata",Source,null,DataTime,MaxValue,TimeSpan.fromMinutes(20));
相关文档:
///<summary>
///备份数据库到本地磁盘
///</summary>
public bool BackUp(string BackUpFile)
{
try
&nbs ......
最近想研究下web service,奈何找遍网络,都是讲些定义性的东西,泛泛而谈,我看的一知半解,不得要领。不过今天总算有点收获,写了 个小的web service例子,就是判断一个数是不是质数。还是老话,给大家起抛砖引玉的作用,只是给大家讲解如何开发最简单的web service程序 。只要入了门槛,以后的路就可以自己走了。
第一, ......
偶尔使用,简单的记录下过程
1.下载Newtonsoft.Json.Net20.dll后,放入Asp.net项目Bin文件夹中.
Newtonsoft.Json.Net20,是一个Object/Json转换工具,这里用来把对象转换成Json格式字符串.
2.树节点Model对象,
public class TreeModel{
private string _i ......
1.TextBox txt=(TextBox)PreviousPage.FindControl("TextBox1");
2.在页面注册投递页的属性
<%@ PreviousPageType VirtualPath="crouspostPage.aspx" %>
在crouspostPage.aspx的代码隐藏类中添加
public TextBox TextBox1
{
get(return _textbox);
}
在页面中Response.Write(PreviousPage. ......