惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
V
Vulnerabilities – Threatpost
Google Online Security Blog
Google Online Security Blog
Hugging Face - Blog
Hugging Face - Blog
L
LINUX DO - 热门话题
云风的 BLOG
云风的 BLOG
P
Proofpoint News Feed
D
Docker
C
Cyber Attacks, Cyber Crime and Cyber Security
MyScale Blog
MyScale Blog
P
Palo Alto Networks Blog
T
Tenable Blog
P
Privacy International News Feed
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Cisco Talos Blog
Cisco Talos Blog
aimingoo的专栏
aimingoo的专栏
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
A
Arctic Wolf
C
Cybersecurity and Infrastructure Security Agency CISA
C
Cisco Blogs
T
Threat Research - Cisco Blogs
NISL@THU
NISL@THU
The Hacker News
The Hacker News
Project Zero
Project Zero
AWS News Blog
AWS News Blog
Simon Willison's Weblog
Simon Willison's Weblog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
Threatpost
V
Visual Studio Blog
The GitHub Blog
The GitHub Blog
The Cloudflare Blog
Last Week in AI
Last Week in AI
Jina AI
Jina AI
Cyberwarzone
Cyberwarzone
The Register - Security
The Register - Security
C
CXSECURITY Database RSS Feed - CXSecurity.com
Vercel News
Vercel News
D
Darknet – Hacking Tools, Hacker News & Cyber Security
MongoDB | Blog
MongoDB | Blog
U
Unit 42
Scott Helme
Scott Helme
A
About on SuperTechFans
WordPress大学
WordPress大学
F
Fortinet All Blogs
大猫的无限游戏
大猫的无限游戏
G
GRAHAM CLULEY
Latest news
Latest news
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Schneier on Security

博客园 - 堕落的卖猪贩

C#控件访问调用它的父级页面 GridView,IE浏览器去掉行右边竖的黑线 用ThoughtWorks.QRCode生成二维码时出现“索引超出了数组界限”的错误 经典情景剧,我爱我家 ASP.NET生成WORD文档,服务器部署注意事项 position:absolute; div居中 WIN2003 IIS6 FastCGI php5.33配置重点 安装程序检测到计算机重新启动操作可能处于挂起状态 的解决方法[转] Windows 2008非服务器使用系统设置 SQL2008安装常见问题 windows 2008安装KB971513,API3.0提示更新不会应用到系统 将远程桌面mstsc放到桌面 ul li做标题列表中间出现多的一个空行,重复。 windows2008配置来 winform笔记 Eval()、XPath() 和 Bind() 这类数据绑定方法只能在数据绑定控件的上下文中使用 - 堕落的卖猪贩 Server Application Unavailable - 堕落的卖猪贩 深度GHOST安装,GHOST完毕后不能启动继续 CSS+JS;JS+CSS换肤总结
ViewState提交后丢失,竟然是OnInit搞的鬼
堕落的卖猪贩 · 2016-12-10 · via 博客园 - 堕落的卖猪贩

提交后报错,断点看ViewStat值没有了。排查半天完全不知道怎么回事。

百度搜索了下ViewState提交丢失。然后CSDN一个帖子说的半拉子话提点了我。

然后想到我经常重写这些函数。以前怎么没遇到。然后检查代码改写后解决,虽然不知道怎么回事,但解决了。

原代码如下:

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    if (!IsPostBack)
    {
        vOrderID = Convert.ToInt32(Request.QueryString["OrderID"]);
    }
}
protected int vOrderID
{
    get
    {
        return (ViewState["vOrderID"] == null) ? 0 : Convert.ToInt32(ViewState["vOrderID"]);
    }
    set
    {
        ViewState["vOrderID"] = value;
    }
}

就出在第一个函数上。改成如下放到OnPreLoad就对了。

protected override void OnPreLoad(EventArgs e)
{
    base.OnPreLoad(e);
    if (!IsPostBack)
    {
        vOrderID = Convert.ToInt32(Request.QueryString["OrderID"]);
    }
}
protected int vOrderID
{
    get
    {
        return (ViewState["vOrderID"] == null) ? 0 : Convert.ToInt32(ViewState["vOrderID"]);
    }
    set
    {
        ViewState["vOrderID"] = value;
    }
}

备忘,同时希望能给大家提供帮助。