同一次PostBack被处理了两次,还有谁遇到过?

Pittypat 2007-08-06 01:32:17
一下是我调试时的堆栈跟踪:
第一次
System.Web.dll!System.Web.UI.DataSourceView.Delete(System.Collections.IDictionary keys, System.Collections.IDictionary oldValues, System.Web.UI.DataSourceViewOperationCallback callback = {System.Web.UI.DataSourceViewOperationCallback}) + 0x28 字节
System.Web.dll!System.Web.UI.WebControls.GridView.HandleDelete(System.Web.UI.WebControls.GridViewRow row, int rowIndex) + 0x3a0 字节
System.Web.dll!System.Web.UI.WebControls.GridView.HandleEvent(System.EventArgs e, bool causesValidation, string validationGroup) + 0x484 字节
System.Web.dll!System.Web.UI.WebControls.GridView.RaisePostBackEvent(string eventArgument) + 0xc8 字节
System.Web.dll!System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument) + 0x8 字节
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument) + 0xc 字节
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Collections.Specialized.NameValueCollection postData) + 0xaf 字节
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint = true, bool includeStagesAfterAsyncPoint = true) + 0x13ef 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint = true) + 0x4d 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest() + 0x57 字节
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) + 0x13 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) + 0x32 字节
App_Web_kbvn7yue.dll!ASP.base_company_salarystdlist_aspx.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}) + 0x2f 字节 C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x9b 字节
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = true) + 0x41 字节
System.Web.dll!System.Web.HttpApplication.ResumeSteps(System.Exception error) + 0x163 字节
System.Web.dll!System.Web.HttpApplication.System.Web.IHttpAsyncHandler.BeginProcessRequest(System.Web.HttpContext context, System.AsyncCallback cb, object extraData) + 0x91 字节
System.Web.dll!System.Web.HttpRuntime.ProcessRequestInternal(System.Web.HttpWorkerRequest wr = {System.Web.Hosting.ISAPIWorkerRequestOutOfProc}) + 0x12d 字节
System.Web.dll!System.Web.HttpRuntime.ProcessRequestNoDemand(System.Web.HttpWorkerRequest wr) + 0x62 字节
System.Web.dll!System.Web.Hosting.ISAPIRuntime.ProcessRequest(System.IntPtr ecb, int iWRType) + 0x57 字节
[应用程序域转换]
[本机到托管的转换]

第二次

System.Web.dll!System.Web.UI.DataSourceView.Delete(System.Collections.IDictionary keys, System.Collections.IDictionary oldValues, System.Web.UI.DataSourceViewOperationCallback callback = {System.Web.UI.DataSourceViewOperationCallback}) + 0x28 字节
System.Web.dll!System.Web.UI.WebControls.GridView.HandleDelete(System.Web.UI.WebControls.GridViewRow row, int rowIndex) + 0x3a0 字节
System.Web.dll!System.Web.UI.WebControls.GridView.HandleEvent(System.EventArgs e, bool causesValidation, string validationGroup) + 0x484 字节
System.Web.dll!System.Web.UI.WebControls.GridView.RaisePostBackEvent(string eventArgument) + 0xc8 字节
System.Web.dll!System.Web.UI.WebControls.GridView.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(string eventArgument) + 0x8 字节
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Web.UI.IPostBackEventHandler sourceControl, string eventArgument) + 0xc 字节
System.Web.dll!System.Web.UI.Page.RaisePostBackEvent(System.Collections.Specialized.NameValueCollection postData) + 0xaf 字节
System.Web.dll!System.Web.UI.Page.ProcessRequestMain(bool includeStagesBeforeAsyncPoint = true, bool includeStagesAfterAsyncPoint = true) + 0x13ef 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest(bool includeStagesBeforeAsyncPoint, bool includeStagesAfterAsyncPoint = true) + 0x4d 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest() + 0x57 字节
System.Web.dll!System.Web.UI.Page.ProcessRequestWithNoAssert(System.Web.HttpContext context) + 0x13 字节
System.Web.dll!System.Web.UI.Page.ProcessRequest(System.Web.HttpContext context) + 0x32 字节
App_Web_kbvn7yue.dll!ASP.base_company_salarystdlist_aspx.ProcessRequest(System.Web.HttpContext context = {System.Web.HttpContext}) + 0x2f 字节 C#
System.Web.dll!System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() + 0x9b 字节
System.Web.dll!System.Web.HttpApplication.ExecuteStep(System.Web.HttpApplication.IExecutionStep step = {System.Web.HttpApplication.CallHandlerExecutionStep}, ref bool completedSynchronously = true) + 0x41 字节
System.Web.dll!System.Web.HttpApplication.ResumeSteps(System.Exception error) + 0x163 字节
System.Web.dll!System.Web.HttpApplication.ResumeStepsFromThreadPoolThread(System.Exception error) + 0x2d 字节
System.Web.dll!System.Web.HttpApplication.AsyncEventExecutionStep.ResumeStepsWithAssert(System.Exception error) + 0x28 字节
System.Web.dll!System.Web.HttpApplication.AsyncEventExecutionStep.OnAsyncEventCompletion(System.IAsyncResult ar) + 0x93 字节
System.Web.dll!System.Web.HttpAsyncResult.Complete(bool synchronous, object result, System.Exception error) + 0x35 字节
System.Web.dll!System.Web.SessionState.SessionStateModule.PollLockedSessionCallback(object state) + 0x11e 字节
mscorlib.dll!System.Threading._TimerCallback.TimerCallback_Context(object state) + 0x1a 字节
mscorlib.dll!System.Threading.ExecutionContext.runTryCode(object userData) + 0x43 字节
[本机到托管的转换]
[托管到本机的转换]
mscorlib.dll!System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0xa7 字节
mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x92 字节
mscorlib.dll!System.Threading._TimerCallback.PerformTimerCallback(object state) + 0x5b 字节
[应用程序域转换]

我发现有很多人提出同一个事件被触发两次的问题,有一些是与AutoEventWireup,有关,但是这里的问题表面上却不是!
这里的代码是在一个GridView的删除操作后跟踪到的,GridView我继承并重写了PerformDataBinding方法。我曾经在国外的论坛上看到说,这与执行删除的Button是ImageButton有关,不知道是否属实(我还没有试过)!
...全文
608 28 打赏 收藏 转发到动态 举报
写回复
用AI写文章
28 条回复
切换为时间正序
请发表友善的回复…
发表回复
linkspeed111 2008-06-02
  • 打赏
  • 举报
回复
我也遇到了,一样地情况
还在查最终原因,也许是ajax出发onload
O15013245O 2007-08-08
  • 打赏
  • 举报
回复
想说的和sp1234说的差不多
Pittypat 2007-08-08
  • 打赏
  • 举报
回复
偶要结贴了!诸位还有没有什么意见?
showmy 2007-08-08
  • 打赏
  • 举报
回复
mark
Pittypat 2007-08-08
  • 打赏
  • 举报
回复
呵呵,我就没有看到init事件,我使用了AutoEventWireup=true来自动注册事件,我跟踪过,没有注册两次,如果我注册了两次,结果一定是要执行四次。问题我变通解决了,是使用LinkButton取代ImageButton。
  • 打赏
  • 举报
回复
是不是你的init里面注册了两次?
zyug 2007-08-07
  • 打赏
  • 举报
回复
我碰到过事件触发了不执行的

要用这种方式手工指定的

//解决值为24时不触发事件的问题
if (Request.Params["__EVENTTARGET"] != null && Request.Params["__EVENTTARGET"].EndsWith("BuyList1$perPageItem") && perPageItem.SelectedValue == "24")
{
BindRepeater();
}
chenguangxi 2007-08-07
  • 打赏
  • 举报
回复
bang ding
balenoww 2007-08-07
  • 打赏
  • 举报
回复
mark
flyzph 2007-08-07
  • 打赏
  • 举报
回复
帮顶
Pittypat 2007-08-07
  • 打赏
  • 举报
回复
从我贴出的代码看,第一次是由:
System.Web.Hosting.ISAPIRuntime.ProcessRequest启动了处理请求的过程
第二次是由:一个TimerCallback启动了处理过程,也就是说,对于同一个PostBack,页面有两个生命周期。我跟踪过,IsPostBack都是true!
hy_lihuan 2007-08-07
  • 打赏
  • 举报
回复
应该不会阿,我觉得还是应该从自己的代码里面找问题;
大多数的运行两次的问题都是page_load里面ispostback造成的,因为和自己的代码关联比较小,所以不容易发现问题;至于是不是bug,我觉得可能性不大;
NekChan 2007-08-07
  • 打赏
  • 举报
回复
采用 IsPostBack 来处理一下吧!
Pittypat 2007-08-07
  • 打赏
  • 举报
回复
感谢各位!在这里提出的问题,是我最近发现的,并且我在各个搜索引擎上搜索时,发现很多人都碰到了类似的问题,并且我还没有发现更好的解决方案!各位说的情况,我基本上都排除了!这个问题只要我把CommandField.ButtonType 由 Image 改为 Button,就不会产生!我正在深入分析和跟踪!
xwk789xwk 2007-08-06
  • 打赏
  • 举报
回复
晕,帮顶
Jinglecat 2007-08-06
  • 打赏
  • 举报
回复
显然事件委托被绑定了两次


这与执行删除的Button是ImageButton有关
========
应该不会,最好仔细调试跟踪

既然自己重写了GridView 确认自己重载方法内部处理是否合理
bigmingming 2007-08-06
  • 打赏
  • 举报
回复
http://topic.csdn.net/t/20031121/13/2480517.html
主要可能还是代码的问题
bigmingming 2007-08-06
  • 打赏
  • 举报
回复
http://www.itpub.net/756900.html
Pittypat 2007-08-06
  • 打赏
  • 举报
回复
感谢各位!感谢 bigmingming ,你提交的解决方案不是我问题的解答!解答是解决了用户对多个PostBack页面(METHOD=POST的form)刷新而导致相同的功能提交了多次,客观上,用户进行了多次提交工作!而我这里只是提交了一次,但是服务器却执行了两次!
  • 打赏
  • 举报
回复
“莫非又一个微软的bug?”这种问题方式过于幼稚,难以给你解答任何专业问题。
加载更多回复(8)

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧