即使在调试中,ASP.NET也不会调用代码

时间:2012-12-17 14:05:07

标签: c# asp.net

正如它所说,当我在调试中运行我的应用程序时,代码隐藏不会被调用。

我开始时遇到了这个问题,并设法通过放弃我正在处理的页面并启动一个全新的页面来解决它。

然而,现在看来这个也已经破了!

基本上它只是打开显示未经修改的HTML而不运行任何C#代码而不会遇到任何断点。

它构建正常,但我还没有尝试部署它,因为我目前没有可用的服务器。

这是我在index.aspx.cs中的代码:

namespace PAPS
{
    public partial class index : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        { 
            string username = User.Identity.Name;
            // check security
            Security security = new Security(username);
            divUsername.InnerText = username;
            security = null;
        }
    }
}

index.aspx的页面声明如下:

<%@ Page Language="C#" AutoEventWireup="false" EnableSessionState="True" EnableViewState="false" CodeBehind="index.aspx.cs" Inherits="PAPS.index" %>

任何人都有任何有用的建议吗?

由于

1 个答案:

答案 0 :(得分:5)

你有

AutoEventWireup = false

除非您自己处理事件,否则请尝试将其设置为true。