问题描述
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.
不,我不会在任何地方调用页面加载函数...
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
5. Variation on the missing img src, body { background-image: url(); }
6. Rewrite rule and missing favicon.ico
最后是我的问题....
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
我对此进行了测试,如果您在 MyPage 中的方法上放置一个 Handles,它将被命中 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 页面中触发两次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!