如何在技术上的IsPostBack工作? [英] How does IsPostback technically work?

查看:118
本文介绍了如何在技术上的IsPostBack工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个奇怪的问题,即从除了谷歌浏览器所有浏览器都注册一个电话到Page_Load事件为真内的IsPostBack当我点击一个asp.net按钮,只是回发到同一页。

I'm currently having a strange issue whereby all browsers except from Google Chrome are registering a call to IsPostback within a Page_Load event as true when I click an asp.net button which simply posts back to the same page.

这使我尝试和探索如何在ASP.NET的页面中IsPostBack属性在技术上实现的,什么我努力寻找。

This has led me to try and discover how the IsPostback property within an ASP .Net page is technically implemented, something I'm struggling to find.

我迄今为止的想法是,它可能与以下;

My thoughts to date are that it could be related to the following;


  • 请求动词类型是POST,而不是GET。

  • 包含视图状态信息隐藏输入有没有信息present,因此没有previously提交的控制信息是可用的。

  • 在请求头HTTP引用相同的URL。

任何人都可以提供用于确定的IsPostBack布尔属性?条件的实际击穿

Can anyone provide an actual breakdown of the conditions used to determine the IsPostback boolean property?

请注意:我正在寻找的实际执行,而不是认知/理论作为我希望用这个来积极解决问题。我也搜索MSDN,迄今无法找到任何技术文章准确地覆盖机制。

Note: I'm looking for the actual implementation rather than perceptions / theory as I'm hoping to use this to actively resolve an issue. I've also searched MSDN and to date cannot find any technical article accurately covering the mechanism.

在此先感谢,
布莱恩。

Thanks in advance, Brian.

推荐答案

页面查找一个 __ preVIOUSPAGE 形式价值的存在。

The page looks for the existence of a __PREVIOUSPAGE form value.

从反射器:

public bool IsPostBack
{
    get
    {   //_requestValueCollection = Form or Querystring name/value pairs
        if (this._requestValueCollection == null)
        {
            return false;
        }

        //_isCrossPagePostBack = _requestValueCollection["__PREVIOUSPAGE"] != null
        if (this._isCrossPagePostBack)
        {
            return true;
        }

        //_pageFlags[8] = this._requestValueCollection["__PREVIOUSPAGE"] == null
        if (this._pageFlags[8])
        {
            return false;
        }

        return (   ((this.Context.ServerExecuteDepth <= 0) 
                || (   (this.Context.Handler != null) 
                    && !(base.GetType() != this.Context.Handler.GetType())))
                && !this._fPageLayoutChanged);
    }
}

这篇关于如何在技术上的IsPostBack工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆