去掉.net页面中的<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE"
.net 网站生成 页面后,会有<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTU5NzgzMjY1MQ8WBh4KUGFnZUNvdW50cwLsAh4JUGFnZUluZGV4Zh4JSnVtcFBhZ2VzAu0CFgICAw9kFhYCBw8QDxYGHg5EYXRhVmFsdWVGaWVsZAUEY19pZB4NRGF0YVRleHRGaWVsZAUHY190aXRsZR4LXyFEYXRhQm91bmRnFgIeCG9uY2hhbmdlBShTaG93KHRoaXMub3B0aW9uc1tzZWxlY3RlZEluZGV4XS52YWx1ZSk7EBUjBuaAu+ermQbljJfkuqwG5aSp5rSlBuS4iua1twbph43luoYG5rWZ5rGfBuaxn+iLjwblub/kuJwG5bGx5LicBuWuieW+vQbmuZbljZcG5Zub5bedBuemj+W7ugbmsZ/opb8G5rKz5Y2XBua5luWMlwnpu5HpvpnmsZ8G5rKz5YyXBui+veWugQblkInmnpcG6LS15beeBuWxseilvwblub/opb8G5LqR5Y2XBumZleilvwblroHlpI8J5YaF6JKZ5Y+kBueUmOiCgwbpnZLmtbcG6KW/6JePBuaWsOeWhgbmtbfljZcG6aaZ5rivBua+s+mXqAblj7Dmub4VIwExATIBMwE0ATUBNgIxOAIxOQIyMAIyMQIyMgIyMwIyNAIyNQIyNgIyNwIyOAIyOQIzMAIzMQIzMgIzMwIzNAIzNQIzNgIzNwIzOAIzOQI0MAI0MQI0MgI0MwI0NAI0NQMzNTQUKwMjZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dnZ2dkZAIJDxYCHglpbm5lcmh0bWwF2hwgPGRpdiBzdHlsZT0ndGV4dC1hbGlnbjpjZW50ZXI7d2lkdGg6MTAwcHg7IGZsb2F0OmxlZnQ7J2NsYXNzPSdqeDAxJz48YSBocmVmPSdqeHNzLTIuaHRtbCc+5YyX5LqsPC9hPjwvZGl2PiA8ZGl2IHN0eWxlPSd0ZXh0LWFsaWduOmNlbnRlcjt3aWR0aDoxMDBweDsgZmxvY
这些东西怎么去掉
我把页面viewstate 设置了false,我在这个页面上 放了个搜索,到其他页面,这就参数没法获取到
望高人指教
[解决办法]
不用去掉
protected override object LoadPageStateFromPersistenceMedium()
{
return null;
}
protected override void SavePageStateToPersistenceMedium(object viewState) { }
重写这两个方法就可以
[解决办法]
一楼说的很详细了
如果你不需要,直接按一楼来就行了,如果出错
那么你需要把 这个方法中的
protected override void SavePageStateToPersistenceMedium(object viewState) { }
viewState参数用其它形式保存下来,当然可能会涉及到一些序列化之类的,参照msdn
在下面
protected override object LoadPageStateFromPersistenceMedium()
{
//还原出你保存的viewState
}
[解决办法]
当然了, 你以为 ViewState是做什么的?
[解决办法]
记得有个高手的帖子介绍ViewState保存在服务端硬盘上的方法,你搜一下,地址我记不住了
[解决办法]
自己去搜索下SP1234的这个帖子
[解决办法]
存到服务器上的还真没仔细研究过。看来得琢磨琢磨了。
[解决办法]
学习
[解决办法]
汗,我去掉这个后我的网站的所有的事件都丢失了
[解决办法]
先确定你真的要去掉viewstate吗
[解决办法]
可以把他存到硬盘上.
不过没必要,那个东西有利也有弊
你可以post,get方法提交
<form action="xxx.aspx" ...>,去掉原来的runat = server
微软的webForm使很多没接触过asp,jsp..等的新手变成了傻子.-_-!
[解决办法]
看看我的问题呀大哥
[解决办法]
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
//添加引用
using System.IO;
using System.Threading;
namespace CCL
{
/// <summary>
/// BasePage 的摘要说明
/// </summary>
public class BasePage : System.Web.UI.Page
{
#region 解决ViewState过于庞大的问题
//由于这里添加了目录,所以要建立App_Data/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
}
}