Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÈÃViewState ±£´æÓÚ·þÎñÆ÷¶ËÎļþ (asp.net C#)

½«ViewState³Ö¾Ã»¯±£³ÖÔÚ·þÎñÆ÷¶ËÎļþµÄ´úÂ룬ÕâÑùViewState²»Õ¼ÓÃÍøÂç´ø¿í£¬Òò´ËÆä´æÈ¡Ö»ÊÇ·þÎñÆ÷µÄ´ÅÅ̶Áȡʱ¼ä¡£²¢ÇÒËüºÜС£¬¿ÉÒÔ˵ÊÇ´ÅÅÌËæ±ãתһȦ¾ÍÄÜͬʱ¶ÁÈ¡ºÃ¶àViewState£¬Òò´Ë¿ÉÒÔ˵“²»Õ¼Ê±¼ä”¡£ÎªÁËÔÙ“²»Õ¼´ÅÅÌʱ¼ä”£¬ÎÒ»¹Ê¹ÓÃÁË»º´æ¡£
´´½¨Ò»¸ö»ùÀà:
public class
BasePage : System.Web.UI.Page
{
protected override object
LoadPageStatefromPersistenceMedium()
{
var viewStateID = (string)((Pair)base.LoadPageStatefromPersistenceMedium()).Second;
var stateStr = (string)Cache[viewStateID];
if (stateStr == null)
{
var fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
stateStr = File.ReadAllText(fn);
}
return new ObjectStateFormatter().Deserialize(stateStr);
}
protected override void
SavePageStateToPersistenceMedium(object state)
{
var value = new ObjectStateFormatter().Serialize(state);
var viewStateID = (DateTime.Now.Ticks + (long)this.GetHashCode()).ToString(); //²úÉúÀëÉ¢µÄidºÅÂë
var fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
ThreadPool.QueueUserWorkItem(obj => File.WriteAllText(fn, value));
Cache.Insert(viewStateID, value);
base.SavePageStateToPersistenceMedium(viewStateID);
}

}
}
Global.asax,ÒÔÏ´úÂëÒ²¿ÉÒÔ²»Óãº
protected void
Application_Start(object sender, EventArgs e)
{
DirectoryInfo dir = new DirectoryInfo(this.Server.MapPath("~/App_Data/ViewState/"));
if (!dir.Exists)
dir.Create();
else
{
DateTime nt = DateTime.Now.AddHours(-0.3); //ɾ³ý15·ÖÖÓÒÔÇ°µÄ»º´æÎļþ
FileInfo[] fiArr = dir.GetFiles();
foreach (FileInfo f in fiArr)
{
if (f.CreationTime < nt)
{
f.Delete();
}
}
}
}
ʹÓ÷½·¨:
ÆäËüÒ³Ã


Ïà¹ØÎĵµ£º

ASP.NETÖÐWebFormsºÍMVC¿ò¼Ü£º¼ÈÉú褺ÎÉúÁÁ£¿(2008

¹ØÓÚASP.NETƽ̨ϵÄWeb FormsºÍMVC£¬Õ§Ò»¿´À´£¬´óÓÐÒ»ÖÖ“¼ÈÉú褺ÎÉúÁÁ”µÄ¸Ð¾õ£¬µ«×øÏÂÀ´×Ðϸ˼¿¼£¬»¹ÊÇÓÐÆä¸÷×Ô´æÔڵĵÀÀíµÄ¡£Ê×ÏÈ,ÎÒÃÇÏÈÀ´¿´Ò»ÏÂWeb Forms, ¼¸ÄêµÄʵ¼ùÖ¤Ã÷Web FormsÊÇÒ»¸ö·Ç³£Îȶ¨ºÍ³ÉÊìµÄƽ̨£¬ÎÞÒÉËüÊÇÇ¿´óµÄ£¬µ«Ò²²»ÊÇÍêÃÀÎÞȱµÄ¡£´ÓÒÔϼ¸¸ö·½ÃæÀ´¿´ËüµÄÇ¿´óÖ®´¦£º
 
1¡¢ÐÔÄÜÓÅÐ ......

Asp.netÖÐDataBinder.Eval Ó÷¨

Asp.netÖÐDataBinder.EvalÓ÷¨µÄ×ܽá
<%# Bind("Subject") %> //°ó¶¨×Ö¶Î
<%# Container.DataItemIndex + 1%> //ʵÏÖ×Ô¶¯±àºÅ
<%# DataBinder.Eval(Container.DataItem, "[n]") %>
ͨ³£Ê¹Óõķ½·¨(ÕâÈý¸öÐÔÄÜ×îºÃ)
<%# DataBinder.Eval(Container.DataItem, "ColumnName") %>
<%# DataBi ......

asp.net Excelµ¼Èë&µ¼³ö


1¡¢ExcelÊý¾Ýµ¼Èëµ½Êý¾Ý¿âÖУº
//¸Ã·½·¨ÊµÏÖ´ÓExcelÖе¼³öÊý¾Ýµ½DataSetÖУ¬ÆäÖÐfilepathΪExcelÎļþµÄ¾ø¶Ô·¾¶£¬sheetnameΪ±íʾÄǸöExcel±í£»
        public DataSet ExcelDataSource( string filepath , string sheetname )
&nb ......

ÕÐƸ£ºasp.net(c#)¸ß¼¶Èí¼þ¹¤³ÌʦһÃû

ÈÎÖ°×ʸñ:
1. ´óѧ±¾¿ÆÒÔÉÏѧÀú£¬ÈýÄêÒÔÉÏÈí¼þ¿ª·¢¹¤×÷¾­Ñé»ò»¥ÁªÍø¿ª·¢¾­Ñ飻¾ßÓжþ¸ö¼°ÒÔÉÏÖÐÐÍÏîÄ¿µÄ³É¹¦ÊµÊ©¾­Ñ飻
2. ÓÐ׼ȷÀí½âÐèÇ󡢼ܹ¹ÄÜÁ¦£¬ÓнÏÇ¿µÄ³ÌÐòÉè¼ÆÄÜÁ¦, ÊìϤÃæÏò¶ÔÏó·ÖÎö¡¢Èí¼þ¹¤³Ì¡¢UMLµÈÏà¹Ø¼¼Êõ£»
3. ÊìÁ·ÕÆÎÕ¼ÆËã»ú±à³ÌÒ»°ã˼ÏëºÍ·½·¨£»ÊìϤһÖÁÁ½ÖÖÃæÏò¶ÔÏó±à³ÌÓïÑÔ£»¾«Í¨.NET¡¢ C#¡¢ASP.net¡ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ