Determine size of ASP.NET page's viewstate before serving page

前端 未结 3 1709
失恋的感觉
失恋的感觉 2020-12-21 01:13

What ASP.NET page lifecycle event can I write code in to determine the size of the viewstate that being sent out? Also, is it possible to determine the size without parsing

3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-21 01:42

    You could use SaveStateCompleted, which occurs right after all the state has been saved to the viewstate. To know the size of the viewstate, just make a character count after calling ToString on the viewstate.

    ViewState.ToString.Count() 
    

提交回复
热议问题