日期:2014-05-17  浏览次数:20455 次

ASP.NET Page_Load执行两次
如题!以为是项目中某些未知的原因造成。新建项目->添加一个新页。Page_Load还是会执行两次,经过跟踪,发现IsPostBack在两次都为false.真不知道什么原因了。
HTML code
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    </div>
    </form>
    
</body>
</html>


C# code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
               
            }
        }
    }
}

求指教。
用firebug 或者fiddler 跟踪http ,显示为一次请求。莫名其妙

------解决方案--------------------
很奇怪啊。

新的空aspx也有这个问题。

看看是不是有***.Designer.***文件,里面有时间捆定?

或者把 AutoEventWireup="true" 设置成false试一试。

------解决方案--------------------
换浏览器试试 汗===