Global.asax
void Application_Start(object sender, EventArgs e)
{
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(this.Server.MapPath("~/App_Data/ViewState/"));
if (!dir.Exists)
dir.Create();
else
{
DateTime nt = DateTime.Now.AddHours(-1);
foreach (System.IO.FileInfo f in dir.GetFiles())
{
if (f.CreationTime < nt)
f.Delete();
}
}
}
A.aspx页面是新闻
#region 解决ViewState过于庞大的问题
protected override object LoadPageStateFromPersistenceMedium()
{
string viewStateID = (string)((Pair)base.LoadPageStateFromPersistenceMedium()).Second;
string stateStr = (string)Cache[viewStateID];
if (stateStr == null)
{
string 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)
{
string value = new ObjectStateFormatter().Serialize(state);
string viewStateID = (DateTime.Now.Ticks + (long)this.GetHashCode()).ToString(); //产生离散的id号码
string fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
//ThreadPool.QueueUserWorkItem(File.WriteAllText(fn, value));
File.WriteAllText(fn, value);
Cache.Insert(viewStateID, value);
base.SavePageStateToPersistenceMedium(viewStateID);
}
#endregion
B.aspx页面是评论
<script type="text/javascript" language="javascript">
function re(){
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","B.aspx",false);
xmlhttp.send();
var str = xmlhttp.responseText;
document.write(str);
}re();
</script>
发布评论就出现标题所示的错误,请教大家
void Application_Start(object sender, EventArgs e)
{
System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(this.Server.MapPath("~/App_Data/ViewState/"));
if (!dir.Exists)
dir.Create();
else
{
DateTime nt = DateTime.Now.AddHours(-1);
foreach (System.IO.FileInfo f in dir.GetFiles())
{
if (f.CreationTime < nt)
f.Delete();
}
}
}
A.aspx页面是新闻
#region 解决ViewState过于庞大的问题
protected override object LoadPageStateFromPersistenceMedium()
{
string viewStateID = (string)((Pair)base.LoadPageStateFromPersistenceMedium()).Second;
string stateStr = (string)Cache[viewStateID];
if (stateStr == null)
{
string 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)
{
string value = new ObjectStateFormatter().Serialize(state);
string viewStateID = (DateTime.Now.Ticks + (long)this.GetHashCode()).ToString(); //产生离散的id号码
string fn = Path.Combine(this.Request.PhysicalApplicationPath, @"App_Data/ViewState/" + viewStateID);
//ThreadPool.QueueUserWorkItem(File.WriteAllText(fn, value));
File.WriteAllText(fn, value);
Cache.Insert(viewStateID, value);
base.SavePageStateToPersistenceMedium(viewStateID);
}
#endregion
B.aspx页面是评论
<script type="text/javascript" language="javascript">
function re(){
var xmlhttp;
try{
xmlhttp=new XMLHttpRequest();
}catch(e){
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","B.aspx",false);
xmlhttp.send();
var str = xmlhttp.responseText;
document.write(str);
}re();
</script>
发布评论就出现标题所示的错误,请教大家
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货