的Page_Load在ASP.NET页面两次射击 [英] Page_Load is firing twice in ASP.NET page

查看:216
本文介绍了的Page_Load在ASP.NET页面两次射击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Asp.net的Page_Load函数加载两次..因此,它会影响我的网页性能。
有谁知道它加载两次的原因。

Asp.net page_load function is loading twice.. hence it affects my page performance. Does anyone know the reason it is loading twice.

没有,IAM没有在任何地方调用页面加载功能...

No, iam not calling the page load function anywhere...

推荐答案

就碰到了这个问题,以为我会发布一个答案,总结我的发现,再加上我的实际问题。

Just ran into this problem, and thought I would post an answer summarizing what I found, plus my actual issue.

1. img tags with src="" or Image tags with ImageUrl="
2. Using AutoEventWireup="true" and adding a page handler
3. Having manually added the event handler (more common for C# than VB)
4. Handling both MyBase.Load and Me.Load

终于我的问题....

and finally my issue....

我的页面从一个类,包括一个页面加载处理程序,它从一个类继承了网页加载处理继承。

My page inherited from a class that included a Page Load handler, which inherited from a class with a Page Load Handler.

Public Class C1
    Inherits System.Web.UI.Page
   Protected Overridable Sub PageLoad(ByVal sender As Object, 
                               ByVal e As System.EventArgs) Handles Me.Load
   End Sub
End Class

Public Class C2
    Inherits C1
    Protected Overrides Sub PageLoad(ByVal sender As Object, 
                      ByVal e As System.EventArgs) Handles Me.Load
        MyBase.PageLoad(sender, e)
    End Sub
End Class

Public Class MyPage 
    Inherits C2
    Protected Overrides Sub PageLoad(ByVal sender As Object, 
                      ByVal e As System.EventArgs) 
        MyBase.PageLoad(sender, e)
    End Sub
End Class

我进行了测试,如果你把一个把手在我的页面的方法,将获得打3次...

I tested this, and if you put a Handles on the method in MyPage, it will get hit 3 times...

这篇关于的Page_Load在ASP.NET页面两次射击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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