如何从更新面板Ajax请求中删除ViewState

本文关键字:请求 删除 ViewState Ajax 更新 | 更新日期: 2023-09-27 18:12:08

我已经在会话中存储了视图状态。然而,当我使用updatepanel时,我仍然看到这个:

| 0 | hiddenField | _ EVENTTARGET | | 0 | hiddenField | _EVENTARGUMENT | | 0 | hiddenField | _ LASTFOCUS | | 72 | hiddenField | _VIEWSTATE |/wEPZwUPOGQwMTViZDAyYzljM2RiDkOzqPgrsrLq7oLjMrtEqvksOkereJ + iwT7JWm4o3eY = | 1 | hiddenField | _ SCROLLPOSITIONX | 0 | 1 | hiddenField | _SCROLLPOSITIONY | 0 | 2524 | hiddenField | __EVENTVALIDATION |/wEdAHT9Fws9F + QU02vyHw9EtdeObLsgjLvX39DC4H8vBJFsyG18cELKaPXq + 6 ahww6b1ru + 8 pzarojcjuc2stbq8lpyrhzezuzo3x7y36pxjtfpwemlgfvdnb/DNXrQtx2v9SFwA6EUH25J8efaI9V + + QjV3oYJ3CPuCO4rknM0UDU/Giw7O8WNpkhgFBXVsNXctDwPxcu09HF7wSzZJLw + yDLL27KCQmMvwyeQidE5tg2IjJwVkoU7oeLVX9C9RJWJzOSAE0IYtgz1LUDFnEzz2hYOu5ayAaskN4ApdAYd5uRg6K90gthxiirKGv + NQoPCw4Y6j7rA2ev411USg9tq7NB9PWYHwL5OwnZ + EXR/NJSLlRHPRrtnXSvGItKU8f0Dp34XG1CYjecxpmI5DuS/QVB3TlY541cQjTzcCv/HsuxlIciiPNCUviC1rvOBSWAA5xRgeRoRdmrXcedawNvUNZNX9qlIl95cg1FFB3mx2hy79XB + FEw3T7oc//ZDu3Y2K2NaCCK9 + JQB0ysMN3aBxKawLkwRYSkH8judvo71vrM731VSHTSByvJ + f9qJ + bkVEjIfqddGEVOgyU0snyHEF8GKyF3iWsXTzAe9Fc2I41sQQfNQ1Mb/i5HmDqpAsKH4S1tt96XgwmzKUAHVyC9YllJNz7KbvuAn9E45Xu y + 82 sy4pl + ocjVp1LzZqKm1zxDydsyYEJyk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0dwhQ6zihZvZgf0XQnIOUH8xjO51ZvyG9VJB5tUVWcjLFrySOmgH oWnIlXMrK44Yzx3gfNbiYs9RJk58u6gCMI0tEmT5Ubg3Mb6oV1O581CKClBM3IGiMNVGZ5GAixwtnbQZwA5eerBurSYQ79Cp5UExRubalAdi7EIXdznejVWgTEmL6oF9xSVXPB/4 b7/Odm4FcDGaCaD7uEjgTdyDCeVA OW2e3hF + dPX92E9a1/ItywkONZRylQmQ5LUb5NE8LVejlFSluTqPTtcGUZ6E1fMIFtKja0pvPJGc + iRhDN2HMOIlGqBVGYhkX1NOBuedASsY0HLFXnvr2L/aU/HQbQlCNJnpwmQGauXnffaIU + kcXsjFrKM74NLrtGQzffpFomEjZOvHZ34GMwGxvjaj4 + 6BtOesA1gpJYB//Yy/J4tMSNePfi6S06BIWWH1lWdRtjzLndYgb aBBtPpuERDmR13pBLUCNjFzYVhMteyaW6iNMyQ4vhimTHpfJmNetj1a8qL + AZ7mflGfEdlBhM5oPVUOYeqPQD + nAlHmqmGopXtSAYNb/zIUrYdEKXomNrF2x0gU3Z8CovtY31qvaFstoyKBokBco1V1RNAmbCIC7qcAV5rT + 5 znsrbwy9k + ltbeK18p5o22ntmveymm7IifzgKdI9Pw9NgqbV/e7Wvj2qjIRH7MVyItXHkfOjP24GZ8IFFCFcT9D/bi0kSfSe36Xk89p1eJrsuNNxL/QRqaq | 0 | asyncPostBackControlIDs | | | 0 | postBackControlIDs | | 102 | | updatePanelIDs | | tctl00身体updIGrp美元,tctl00身体updITyp美元,美元,tctl00身体updRpt,美元,tctl00 tctl00身体updSrch美元,美元身体updDoc美元| 0 | childUpdatePanelIDs | | | | 57 panelsToRefreshIDs | | ctl00身体updRpt美元,ctl00身体updSrch美元,美元,ctl00身体updDoc美元,| 2 | asyncPostBackTimeout | | 90 | 0 | formAction | | | 39 | scriptStartupBlock | ScriptContentNoTags | removeLastColumn (ctl00_Body_grvDocs); | 208 | scriptStartupBlock | ScriptContentNoTags | Sys.Application.add_init(函数(){$创建(Sys.UI._UpdateProgress{"associatedUpdatePanelId":"ctl00_Body_updRpt"、"displayAfter":0,"dynamicLayout":假},null, null, $get("ctl00_Body_ctl07"));

是否有任何方法可以防止在响应中发送此内容?

如何从更新面板Ajax请求中删除ViewState

摘自stackoverflow:

__VIEWSTATE字段也用于存储控制状态,这是不是可选的。此外,视图状态中包含的信息是用来验证回发的,如果我没记错的话(和validation是启用的,这是默认的)。只要你有表格使用runat="server",您将拥有一个viewstate字段。然而,你如果你禁用所有的viewstate,应该会注意到一个小得多的字段大小。

顺便说一下,有一些技巧可以删除视图状态。查看以下帖子:

用Regex覆盖渲染并剥离ViewState

在UpdatePanel上设置'EnableViewState=false'。这将禁用包含在的所有子控件的ViewState。或者,如果您需要更细粒度的方法,您也可以逐个控件禁用ViewState。